def read_nq_examples(input_file, is_training):
  """Read a NQ json file into a list of NqExample."""
  input_paths = tf.gfile.Glob(input_file)
  input_data = []

  def _open(path):
    if path.endswith(".gz"):
      return gzip.GzipFile(fileobj=tf.gfile.Open(path, "rb"))
    else:
      return tf.gfile.Open(path, "r")

  for path in input_paths:
    tf.logging.info("Reading: %s", path)
    with _open(path) as input_file:
      for line in input_file:
        input_data.append(create_example_from_jsonl(line))

  examples = []
  for entry in input_data:
    examples.extend(read_nq_entry(entry, is_training))
  return examples
Read a NQ json file into a list of NqExample.
language/question_answering/bert_joint/run_nq.py