# Path: px/environments/docqa.py
# class DocqaEnvironment(object):
#   def __init__(self,
#                precomputed_data_path,
#                corpus_dir,
#                model_dir,
#                nltk_dir,
#                async=0,
#                batch_size=32,
#                corpus_name="wiki",
#                debug_mode=False,
#                filter_name=None,
#                load_test=False,
#                max_answer_len=8,
#                max_tokens=400,
#                n_paragraphs=5,
#                n_processes=12,
#                step="latest"):
#   def GetAnswers(self, questions, document_ids):
#   def best_answers(self, dataframe):
#   def load_data(self, precomputed_data_path, corpus_name, corpus_dir, nltk_dir,
#                 datasets, filter_name, n_paragraphs, n_processes):


from concurrent import futures
from absl import app
from absl import flags
from absl import logging
from px.environments import docqa
from px.environments import docqa_squad
from px.proto import aqa_pb2
from px.proto import aqa_pb2_grpc
import time
import grpc
    self.debug_mode = debug_mode
    if model_type == 'triviaqa':
      self._InitializeEnvironment(
          precomputed_data_path=precomputed_data_path,
          corpus_dir=corpus_dir,
          model_dir=model_dir,
          nltk_dir=nltk_dir,
          load_test=load_test,
          debug_mode=debug_mode)
    elif model_type == 'squad':
      self._InitializeSquadEnvironment(
          corpus_dir=corpus_dir,
          corpus_name=corpus_name,
          corpus_part=corpus_part,
          model_dir=model_dir,
          nltk_dir=nltk_dir)

  def _InitializeEnvironment(self, precomputed_data_path, corpus_dir, model_dir,
                             nltk_dir, load_test, debug_mode):
    """Initilizes the DocQA model environment.

    Args:
      precomputed_data_path: Path to the precomputed data stored in a pickle
          file.
      corpus_dir: Path to corpus directory.
      model_dir: Directory containing parameters of a pre-trained DocQA model.
      nltk_dir: Folder containing the nltk package.
      load_test: If True, loads the test set as well.
      debug_mode: If true, logs additional debug information.
    """

# Path: px/environments/docqa.py
# class DocqaEnvironment(object):
#   def __init__(self,
#                precomputed_data_path,
#                corpus_dir,
#                model_dir,
#                nltk_dir,
#                async=0,
#                batch_size=32,
#                corpus_name="wiki",
#                debug_mode=False,
#                filter_name=None,
#                load_test=False,
#                max_answer_len=8,
#                max_tokens=400,
#                n_paragraphs=5,
#                n_processes=12,
#                step="latest"):
#   def GetAnswers(self, questions, document_ids):
#   def best_answers(self, dataframe):
#   def load_data(self, precomputed_data_path, corpus_name, corpus_dir, nltk_dir,
#                 datasets, filter_name, n_paragraphs, n_processes):


# Path: px/environments/docqa_server.py
from concurrent import futures
from absl import app
from absl import flags
from absl import logging
from px.environments import docqa
from px.environments import docqa_squad
from px.proto import aqa_pb2
from px.proto import aqa_pb2_grpc
import time
import grpc

    self.debug_mode = debug_mode
    if model_type == 'triviaqa':
      self._InitializeEnvironment(
          precomputed_data_path=precomputed_data_path,
          corpus_dir=corpus_dir,
          model_dir=model_dir,
          nltk_dir=nltk_dir,
          load_test=load_test,
          debug_mode=debug_mode)
    elif model_type == 'squad':
      self._InitializeSquadEnvironment(
          corpus_dir=corpus_dir,
          corpus_name=corpus_name,
          corpus_part=corpus_part,
          model_dir=model_dir,
          nltk_dir=nltk_dir)

  def _InitializeEnvironment(self, precomputed_data_path, corpus_dir, model_dir,
                             nltk_dir, load_test, debug_mode):
    """Initilizes the DocQA model environment.

    Args:
      precomputed_data_path: Path to the precomputed data stored in a pickle
          file.
      corpus_dir: Path to corpus directory.
      model_dir: Directory containing parameters of a pre-trained DocQA model.
      nltk_dir: Folder containing the nltk package.
      load_test: If True, loads the test set as well.
      debug_mode: If true, logs additional debug information.
    """

    self._environment = docqa.DocqaEnvironment(