class_docstr: Wrapper class for Mesh-TF models.
class_docstr_tok: ["Wrapper","class","for","Mesh-TF","models","."]
docstr: Helper function used by eval method to generate predictions or scores.
  
  Args:
    tasks: list, list of valid tasks to generate predictions or scores.
    vocabulary: a t5.data.vocabulary object or a tuple with separate
      vocabularies for inputs and targets,
    checkpoint_step: integer, step to evaluate the tasks.
    sequence_length: a dict, dictionary with sequence length for inputs and
      targets.
    split: string, split to run the evaluation on.
    eval_with_score: bool, whether to compute log likelihood of targets
      instead of predictions.
  Returns:
    list of decoded predictions or scores depending on eval_with_score flag.
docstr_tok: ["Helper","function","used","by","eval","method","to","generate","predictions","or","scores",".","Args",":","tasks",":","list",",","list","of","valid","tasks","to","generate","predictions","or","scores",".","vocabulary",":","a","t5.data.vocabulary","object","or","a","tuple","with","separate","vocabularies","for","inputs","and","targets",",","checkpoint_step",":","integer",",","step","to","evaluate","the","tasks",".","sequence_length",":","a","dict",",","dictionary","with","sequence","length","for","inputs","and","targets",".","split",":","string",",","split","to","run","the","evaluation","on",".","eval_with_score",":","bool",",","whether","to","compute","log","likelihood","of","targets","instead","of","predictions",".","Returns",":","list","of","decoded","predictions","or","scores","depending","on","eval_with_score","flag","."]
code: def _predict_or_score_fn(
      self,
      tasks,
      vocabulary,
      checkpoint_step,
      sequence_length,
      split,
      eval_with_score=False,
      **unused_kwargs,
  ):
      """Helper function used by eval method to generate predictions or scores.
  
      Args:
        tasks: list, list of valid tasks to generate predictions or scores.
        vocabulary: a t5.data.vocabulary object or a tuple with separate
          vocabularies for inputs and targets,
        checkpoint_step: integer, step to evaluate the tasks.
        sequence_length: a dict, dictionary with sequence length for inputs and
          targets.
        split: string, split to run the evaluation on.
        eval_with_score: bool, whether to compute log likelihood of targets
          instead of predictions.
      Returns:
        list of decoded predictions or scores depending on eval_with_score flag.
      """
      estimator = self.estimator(
          vocabulary,
          score_in_predict_mode=eval_with_score,
          sequence_length=sequence_length,
      )
  
      def estimator_input_fn(params):
          """Eval input function for estimator."""
          del params
          # Concatenate all dataset inputs to only have to do one decode loop
          combined_ds = None
          for task in tasks:
              ds = mesh_transformer.mesh_eval_dataset_fn(
                  mixture_or_task_name=task.name,
                  sequence_length=sequence_length,
                  dataset_split=split,
              )[0].dataset_fn()
              ds = ds.map(
                  utils.filter_features,
                  num_parallel_calls=tf.data.experimental.AUTOTUNE,
              )
              combined_ds = (
                  ds if not combined_ds else combined_ds.concatenate(ds)
              )
          combined_ds = combined_ds.batch(
              self.batch_size, drop_remainder=False
          )  # pytype:disable=attribute-error
          # Pad the final batch.
          combined_ds = transformer_dataset.trim_and_pad_dataset(
              combined_ds, length=self.batch_size
          )
          combined_ds = combined_ds.prefetch(
              tf.data.experimental.AUTOTUNE
          )
          return combined_ds
  
      checkpoint_path = os.path.join(
          self._model_dir, "model.ckpt-{}".format(checkpoint_step)
      )
      if eval_with_score:
          outputs, _ = mtf_utils.score_with_estimator(
              estimator,
              estimator_input_fn,
              checkpoint_step,
              self._model_dir,
              vocabulary,
          )
      else:
          outputs = [
              tf.compat.as_text(d)
              for d in mtf_utils.decode(
                  estimator,
                  estimator_input_fn,
                  vocabulary,
                  checkpoint_path,
              )
          ]
  
      return outputs
  
imports: import functools
  import os
  import gin
  import gin.tf
  import mesh_tensorflow
  from mesh_tensorflow import optimize
  from mesh_tensorflow.transformer import dataset
  from mesh_tensorflow.transformer import learning_rate_schedules
  from mesh_tensorflow.transformer import utils
  from t5.models import mesh_transformer
  from t5.models import utils
  from t5.models.t5_model import T5Model
  import tensorflow.compat.v1
label_desc: Use image node_id 6 for calling the MtfModel obj's underlying member method code with example usage: obj._predict_or_score_fn(tasks, vocabulary, checkpoint_step, sequence_length, split, eval_with_score) and returns: outputs, combined_ds