def read_entries(input_jsonl_pattern: Text,
                 tokenizer: tok_interface.TokenizerWithOffsets,
                 max_passages: int, max_position: int, fail_on_invalid: bool):
  """Reads TyDi QA examples from JSONL files.

  Args:
    input_jsonl_pattern: Glob of the gzipped JSONL files to read.
    tokenizer: Used to create special marker symbols to insert into the text.
    max_passages: see FLAGS.max_passages.
    max_position: see FLAGS.max_position.
    fail_on_invalid: Immediately stop if an error is found?

  Yields:
    tuple:
      input_file: str
      line_no: int
      tydi_entry: "TyDiEntry"s, dicts as returned by `create_entry_from_json`,
        one per line of the input JSONL files.
      debug_info: Dict containing debugging data.
  """
  matches = tf.gfile.Glob(input_jsonl_pattern)
  if not matches:
    raise ValueError(f"No files matched: {input_jsonl_pattern}")
  for input_path in matches:
    with gzip.GzipFile(fileobj=tf.gfile.Open(input_path, "rb")) as input_file:  # pytype: disable=wrong-arg-types
      for line_no, line in enumerate(input_file, 1):
        json_elem = json.loads(line, object_pairs_hook=collections.OrderedDict)
        entry = preproc.create_entry_from_json(
            json_elem,
            tokenizer,
            max_passages=max_passages,
            max_position=max_position,
            fail_on_invalid=fail_on_invalid)

        if not entry:
          tf.logging.info("Invalid Example %d", json_elem["example_id"])
          if fail_on_invalid:
            raise ValueError("Invalid example at {}:{}".format(
                input_path, line_no))

        # Return a `debug_info` dict that methods throughout the codebase
        # append to with debugging information.
        debug_info = {"json": json_elem}
        yield input_path, line_no, entry, debug_info
Reads TyDi QA examples from JSONL files.

  Args:
    input_jsonl_pattern: Glob of the gzipped JSONL files to read.
    tokenizer: Used to create special marker symbols to insert into the text.
    max_passages: see FLAGS.max_passages.
    max_position: see FLAGS.max_position.
    fail_on_invalid: Immediately stop if an error is found?

  Yields:
    tuple:
      input_file: str
      line_no: int
      tydi_entry: "TyDiEntry"s, dicts as returned by `create_entry_from_json`,
        one per line of the input JSONL files.
      debug_info: Dict containing debugging data.
  
language/canine/tydiqa/tf_io.py