docstr: Computes the metrics given the prediction labels and the true labels.
  
  Parameters
  ----------
  y_pred
      Prediction labels.
  y_true
      True labels.
docstr_tok: ["Computes","the","metrics","given","the","prediction","labels","and","the","true","labels",".","Parameters","--","--","--","--","--","y_pred","Prediction","labels",".","y_true","True","labels","."]
code: def compute_metrics(
      self,
      y_pred: Union[torch.Tensor, List[torch.Tensor]],
      y_true: Union[torch.Tensor, List[torch.Tensor]],
  ) -> Dict[str, float]:
      """
      Computes the metrics given the prediction labels and the true labels.
  
      Parameters
      ----------
      y_pred
          Prediction labels.
      y_true
          True labels.
      """
      results = dict()
  
      if isinstance(self.metrics, dict):
          for name in self.metrics:
              i = (
                  int(name.split("_")[1]) - 1
              )  # name is of the form output_1_... . Maybe we use re?
              self.metrics[name].compute_metric(
                  y_pred=y_pred[i], y_true=y_true[i]
              )
  
              # add output prefix in front of the results
              result = {
                  name + "_" + key: val
                  for key, val in self.metrics[name].result().items()
              }
              results.update(result)
  
      else:  # this is just for one head
          assert isinstance(y_pred, torch.Tensor)
          assert isinstance(y_true, torch.Tensor)
  
          for metric in self.metrics:
              metric.compute_metric(y_pred=y_pred, y_true=y_true)
              results.update(metric.result())
  
      return results
  
imports: import torch
  import torch.nn
  import torch.optim
  from torch.utils.data import DataLoader
  from tqdm import tqdm
  from typing import List, Dict, Callable, Union, Tuple, Optional
  from alibi.models.pytorch.metrics import Metric, LossContainer
label_desc: Use image node_id 5 for calling the Model obj's underlying member method code with example usage: obj.compute_metrics(y_pred, y_true) and returns: results