# Path: t5/models/utils.py
# _MODEL_FEATURES = [
#     "inputs", "inputs_position", "inputs_segmentation", "targets",
#     "targets_position", "targets_segmentation", "targets_subsegmentation"
# ]
# def filter_features(ex):
# def write_lines_to_file(lines, filename):
# def get_step_from_checkpoint_path(checkpoint_path):
# def write_targets_and_examples(summary_dir, targets, datasets):
# def get_vocabulary(mixture_or_task_name=None):
# def get_latest_checkpoint_from_dir(model_dir):
# def get_checkpoints_iterator(checkpoint_steps, model_dir):
#   def _get_closest_checkpoint(target_checkpoint):
#     def _generate_checkpoints():
#   def __call__(
#       self,
#       checkpoint_step: int,
#       vocabulary: seqio.Vocabulary,
#       tasks: Sequence[seqio.Task],
#       datasets: Mapping[str, tf.data.Dataset],
#       sequence_length: Union[None, Mapping[str, int]]
#   ) -> MutableSequence[Union[str, float]]: ...
#   def __call__(
#       self,
#       task: seqio.Task,
#       sequence_length: Mapping[str, int],
#       split: str,
#   ) -> tf.data.Dataset: ...
# def run_eval(
#     mixture_or_task_name: str,
#     predict_or_score_fn: PredictOrScoreFnCallable,
#     checkpoint_steps: Iterable[int],
#     dataset_fn: DatasetFnCallable,
#     summary_dir: Optional[str] = None,
#     split: Optional[str] = "validation",
#     sequence_length: Optional[Mapping[str, int]] = None,
#     batch_size: Optional[int] = None):
# class PredictOrScoreFnCallable(typing_extensions.Protocol):
# class DatasetFnCallable(typing_extensions.Protocol):


import functools
import gin
import mesh_tensorflow.transformer.dataset as transformer_dataset
import t5.data
import tensorflow.compat.v1 as tf
import tensorflow_datasets as tfds
from absl import logging
from t5.models import utils as model_utils
        transformer_dataset.EvalDataset(
            task.name,
            functools.partial(
                _get_dataset_for_single_task,
                task=task,
                sequence_length=sequence_length),
            task.postprocess_fn,
            task.metric_fns,
        )
    )

  if not outputs:
    logging.warning("No %s data found for %s.",
                    dataset_split, mixture_or_task_name)

  return outputs


@gin.configurable()
def tsv_dataset_fn(
    filename,
    sequence_length,
    dataset_split,
    vocabulary,
    shuffle_buffer_size=10000):
  r"""Returns a dataset based on a TSV file formatted as `<input>\t<target>`."""
  # Currently `tf.gfile.glob` is broken on GCS, so we only read a file or
  # list of files.
  return transformer_dataset.packed_parallel_tsv_dataset(
      dataset=tf.data.TextLineDataset(filename).shuffle(shuffle_buffer_size),

# Path: t5/models/utils.py
# _MODEL_FEATURES = [
#     "inputs", "inputs_position", "inputs_segmentation", "targets",
#     "targets_position", "targets_segmentation", "targets_subsegmentation"
# ]
# def filter_features(ex):
# def write_lines_to_file(lines, filename):
# def get_step_from_checkpoint_path(checkpoint_path):
# def write_targets_and_examples(summary_dir, targets, datasets):
# def get_vocabulary(mixture_or_task_name=None):
# def get_latest_checkpoint_from_dir(model_dir):
# def get_checkpoints_iterator(checkpoint_steps, model_dir):
#   def _get_closest_checkpoint(target_checkpoint):
#     def _generate_checkpoints():
#   def __call__(
#       self,
#       checkpoint_step: int,
#       vocabulary: seqio.Vocabulary,
#       tasks: Sequence[seqio.Task],
#       datasets: Mapping[str, tf.data.Dataset],
#       sequence_length: Union[None, Mapping[str, int]]
#   ) -> MutableSequence[Union[str, float]]: ...
#   def __call__(
#       self,
#       task: seqio.Task,
#       sequence_length: Mapping[str, int],
#       split: str,
#   ) -> tf.data.Dataset: ...
# def run_eval(
#     mixture_or_task_name: str,
#     predict_or_score_fn: PredictOrScoreFnCallable,
#     checkpoint_steps: Iterable[int],
#     dataset_fn: DatasetFnCallable,
#     summary_dir: Optional[str] = None,
#     split: Optional[str] = "validation",
#     sequence_length: Optional[Mapping[str, int]] = None,
#     batch_size: Optional[int] = None):
# class PredictOrScoreFnCallable(typing_extensions.Protocol):
# class DatasetFnCallable(typing_extensions.Protocol):


# Path: t5/models/mesh_transformer.py
import functools
import gin
import mesh_tensorflow.transformer.dataset as transformer_dataset
import t5.data
import tensorflow.compat.v1 as tf
import tensorflow_datasets as tfds
from absl import logging
from t5.models import utils as model_utils

        transformer_dataset.EvalDataset(
            task.name,
            functools.partial(
                _get_dataset_for_single_task,
                task=task,
                sequence_length=sequence_length),
            task.postprocess_fn,
            task.metric_fns,
        )
    )

  if not outputs:
    logging.warning("No %s data found for %s.",
                    dataset_split, mixture_or_task_name)

  return outputs


@gin.configurable()
def tsv_dataset_fn(
    filename,
    sequence_length,
    dataset_split,
    vocabulary,
    shuffle_buffer_size=10000):
  r"""Returns a dataset based on a TSV file formatted as `<input>\t<target>`."""
  # Currently `tf.gfile.glob` is broken on GCS, so we only read a file or
  # list of files.
  return transformer_dataset.packed_parallel_tsv_dataset(
      dataset=tf.data.TextLineDataset(filename).shuffle(shuffle_buffer_size),

      sequence_length=sequence_length,