docstr: Run prediction and returns predictions and potential metrics.
  
  Depending on the dataset and your use case, your test dataset may contain labels. In that case, this method
  will also return metrics, like in `evaluate()`.
  
  Args:
      test_dataset (`Dataset`):
          Dataset to run the predictions on. If it is a [`~datasets.Dataset`], columns not accepted by the
          `model.forward()` method are automatically removed. Has to implement the method `__len__`
      ignore_keys (`List[str]`, *optional*):
          A list of keys in the output of your model (if it is a dictionary) that should be ignored when
          gathering predictions.
      metric_key_prefix (`str`, *optional*, defaults to `"eval"`):
          An optional prefix to be used as the metrics key prefix. For example the metrics "bleu" will be named
          "eval_bleu" if the prefix is `"eval"` (default)
      max_length (`int`, *optional*):
          The maximum target length to use when predicting with the generate method.
      num_beams (`int`, *optional*):
          Number of beams for beam search that will be used when predicting with the generate method. 1 means no
          beam search.
      gen_kwargs:
          Additional `generate` specific kwargs.
  
  <Tip>
  
  If your predictions or labels have different sequence lengths (for instance because you're doing dynamic
  padding in a token classification task) the predictions will be padded (on the right) to allow for
  concatenation into one array. The padding index is -100.
  
  </Tip>
  
  Returns: *NamedTuple* A namedtuple with the following keys:
  
      - predictions (`np.ndarray`): The predictions on `test_dataset`.
      - label_ids (`np.ndarray`, *optional*): The labels (if the dataset contained some).
      - metrics (`Dict[str, float]`, *optional*): The potential dictionary of metrics (if the dataset contained
        labels).
docstr_tok: ["Run","prediction","and","returns","predictions","and","potential","metrics",".","Depending","on","the","dataset","and","your","use","case",",","your","test","dataset","may","contain","labels",".","In","that","case",",","this","method","will","also","return","metrics",",","like","in","`","evaluate","(",")","`",".","Args",":","test_dataset","(","`","Dataset","`",")",":","Dataset","to","run","the","predictions","on",".","If","it","is","a","[","`","~datasets.Dataset","`","]",",","columns","not","accepted","by","the","`","model.forward","(",")","`","method","are","automatically","removed",".","Has","to","implement","the","method","`","__len__","`","ignore_keys","(","`","List","[","str","]","`",",","*","optional","*",")",":","A","list","of","keys","in","the","output","of","your","model","(","if","it","is","a","dictionary",")","that","should","be","ignored","when","gathering","predictions",".","metric_key_prefix","(","`","str","`",",","*","optional","*",",","defaults","to","`","``","eval","''","`",")",":","An","optional","prefix","to","be","used","as","the","metrics","key","prefix",".","For","example","the","metrics","``","bleu","''","will","be","named","``","eval_bleu","''","if","the","prefix","is","`","``","eval","''","`","(","default",")","max_length","(","`","int","`",",","*","optional","*",")",":","The","maximum","target","length","to","use","when","predicting","with","the","generate","method",".","num_beams","(","`","int","`",",","*","optional","*",")",":","Number","of","beams","for","beam","search","that","will","be","used","when","predicting","with","the","generate","method",".","1","means","no","beam","search",".","gen_kwargs",":","Additional","`","generate","`","specific","kwargs",".","<","Tip",">","If","your","predictions","or","labels","have","different","sequence","lengths","(","for","instance","because","you","'re","doing","dynamic","padding","in","a","token","classification","task",")","the","predictions","will","be","padded","(","on","the","right",")","to","allow","for","concatenation","into","one","array",".","The","padding","index","is","-100",".","<","\/Tip",">","Returns",":","*","NamedTuple","*","A","namedtuple","with","the","following","keys",":","-","predictions","(","`","np.ndarray","`",")",":","The","predictions","on","`","test_dataset","`",".","-","label_ids","(","`","np.ndarray","`",",","*","optional","*",")",":","The","labels","(","if","the","dataset","contained","some",")",".","-","metrics","(","`","Dict","[","str",",","float","]","`",",","*","optional","*",")",":","The","potential","dictionary","of","metrics","(","if","the","dataset","contained","labels",")","."]
code: def predict(
      self,
      test_dataset: Dataset,
      ignore_keys: Optional[List[str]] = None,
      metric_key_prefix: str = "test",
      **gen_kwargs,
  ) -> PredictionOutput:
      """
      Run prediction and returns predictions and potential metrics.
  
      Depending on the dataset and your use case, your test dataset may contain labels. In that case, this method
      will also return metrics, like in `evaluate()`.
  
      Args:
          test_dataset (`Dataset`):
              Dataset to run the predictions on. If it is a [`~datasets.Dataset`], columns not accepted by the
              `model.forward()` method are automatically removed. Has to implement the method `__len__`
          ignore_keys (`List[str]`, *optional*):
              A list of keys in the output of your model (if it is a dictionary) that should be ignored when
              gathering predictions.
          metric_key_prefix (`str`, *optional*, defaults to `"eval"`):
              An optional prefix to be used as the metrics key prefix. For example the metrics "bleu" will be named
              "eval_bleu" if the prefix is `"eval"` (default)
          max_length (`int`, *optional*):
              The maximum target length to use when predicting with the generate method.
          num_beams (`int`, *optional*):
              Number of beams for beam search that will be used when predicting with the generate method. 1 means no
              beam search.
          gen_kwargs:
              Additional `generate` specific kwargs.
  
      <Tip>
  
      If your predictions or labels have different sequence lengths (for instance because you're doing dynamic
      padding in a token classification task) the predictions will be padded (on the right) to allow for
      concatenation into one array. The padding index is -100.
  
      </Tip>
  
      Returns: *NamedTuple* A namedtuple with the following keys:
  
          - predictions (`np.ndarray`): The predictions on `test_dataset`.
          - label_ids (`np.ndarray`, *optional*): The labels (if the dataset contained some).
          - metrics (`Dict[str, float]`, *optional*): The potential dictionary of metrics (if the dataset contained
            labels).
      """
  
      gen_kwargs = gen_kwargs.copy()
      if (
          gen_kwargs.get("max_length") is None
          and gen_kwargs.get("max_new_tokens") is None
      ):
          gen_kwargs["max_length"] = self.args.generation_max_length
      gen_kwargs["num_beams"] = (
          gen_kwargs["num_beams"]
          if gen_kwargs.get("num_beams") is not None
          else self.args.generation_num_beams
      )
      self._gen_kwargs = gen_kwargs
  
      return super().predict(
          test_dataset,
          ignore_keys=ignore_keys,
          metric_key_prefix=metric_key_prefix,
      )
  
file_path: H2O/h2o_flexgen/benchmark/third_party/transformers/src/transformers/trainer_seq2seq.py
imports: from typing import Any, Dict, List, Optional, Tuple, Union
  import torch
  from torch import nn
  from torch.utils.data import Dataset
  from .deepspeed import is_deepspeed_zero3_enabled
  from .trainer import Trainer
  from .trainer_utils import PredictionOutput
  from .utils import logging
label_desc: Use image node_id 2 for calling the Seq2SeqTrainer obj's underlying member method code with example usage: obj.predict(test_dataset, ignore_keys, metric_key_prefix) and returns: super