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 :obj:`evaluate()`.
  
  Args:
      test_dataset (:obj:`Dataset`):
          Dataset to run the predictions on. If it is an :obj:`datasets.Dataset`, columns not accepted by the
          ``model.forward()`` method are automatically removed. Has to implement the method :obj:`__len__`
      ignore_keys (:obj:`Lst[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 (:obj:`str`, `optional`, defaults to :obj:`"test"`):
          An optional prefix to be used as the metrics key prefix. For example the metrics "bleu" will be named
          "test_bleu" if the prefix is "test" (default)
  
  .. note::
  
      If your predictions or labels have different sequence length (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.
  
  Returns: `NamedTuple` A namedtuple with the following keys:
  
      - predictions (:obj:`np.ndarray`): The predictions on :obj:`test_dataset`.
      - label_ids (:obj:`np.ndarray`, `optional`): The labels (if the dataset contained some).
      - metrics (:obj:`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",":","obj",":","`","evaluate","(",")","`",".","Args",":","test_dataset","(",":","obj",":","`","Dataset","`",")",":","Dataset","to","run","the","predictions","on",".","If","it","is","an",":","obj",":","`","datasets.Dataset","`",",","columns","not","accepted","by","the","``","model.forward","(",")","``","method","are","automatically","removed",".","Has","to","implement","the","method",":","obj",":","`","__len__","`","ignore_keys","(",":","obj",":","`","Lst","[","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","(",":","obj",":","`","str","`",",","`","optional","`",",","defaults","to",":","obj",":","`","``","test","''","`",")",":","An","optional","prefix","to","be","used","as","the","metrics","key","prefix",".","For","example","the","metrics","``","bleu","''","will","be","named","``","test_bleu","''","if","the","prefix","is","``","test","''","(","default",")","..","note",":",":","If","your","predictions","or","labels","have","different","sequence","length","(","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",".","Returns",":","`","NamedTuple","`","A","namedtuple","with","the","following","keys",":","-","predictions","(",":","obj",":","`","np.ndarray","`",")",":","The","predictions","on",":","obj",":","`","test_dataset","`",".","-","label_ids","(",":","obj",":","`","np.ndarray","`",",","`","optional","`",")",":","The","labels","(","if","the","dataset","contained","some",")",".","-","metrics","(",":","obj",":","`","Dict","[","str",",","float","]","`",",","`","optional","`",")",":","The","potential","dictionary","of","metrics","(","if","the","dataset","contained","labels",")","."]
code: def predict(self, test_dataset: Dataset) -> 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 :obj:`evaluate()`.
  
      Args:
          test_dataset (:obj:`Dataset`):
              Dataset to run the predictions on. If it is an :obj:`datasets.Dataset`, columns not accepted by the
              ``model.forward()`` method are automatically removed. Has to implement the method :obj:`__len__`
          ignore_keys (:obj:`Lst[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 (:obj:`str`, `optional`, defaults to :obj:`"test"`):
              An optional prefix to be used as the metrics key prefix. For example the metrics "bleu" will be named
              "test_bleu" if the prefix is "test" (default)
  
      .. note::
  
          If your predictions or labels have different sequence length (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.
  
      Returns: `NamedTuple` A namedtuple with the following keys:
  
          - predictions (:obj:`np.ndarray`): The predictions on :obj:`test_dataset`.
          - label_ids (:obj:`np.ndarray`, `optional`): The labels (if the dataset contained some).
          - metrics (:obj:`Dict[str, float]`, `optional`): The potential dictionary of metrics (if the dataset
            contained labels).
      """
      test_dataloader = self.get_test_dataloader(test_dataset)
  
      output = self._prediction_loop(
          test_dataloader, description="Prediction"
      )
  
      self.log(output.metrics)
  
      return PredictionOutput(
          predictions=output.predictions,
          label_ids=output.label_ids,
          metrics=output.metrics,
      )
  
imports: import collections
  import logging
  import os
  from dataclasses import dataclass, field
  from typing import Callable, Dict, List, Optional, Tuple, Union
  import numpy
  import torch
  from torch.utils.data import DataLoader
  from torch.utils.data.dataset import Dataset
  from tqdm import tqdm
  from adapters import AdapterTrainer
  from transformers import DataCollator, EvalPrediction, PreTrainedModel, PreTrainedTokenizerBase, Trainer, TrainerCallback, TrainingArguments, is_torch_tpu_available
  from transformers.trainer_utils import PredictionOutput
label_desc: Use image node_id 3 for calling the DependencyParsingTrainer obj's underlying member method code with example usage: obj.predict(test_dataset) and returns: PredictionOutput