class_docstr: Evaluator used for tasseo global metrics evaluation.
docstr: Computes the relevant metrics for all added <target, output> pairs.
docstr_tok: ["Computes","the","relevant","metrics","for","all","added","<","target",",","output",">","pairs","."]
code: def compute_metrics(
      self, clear_annotations: Optional[bool] = True
  ) -> Dict[str, Any]:
      """Computes the relevant metrics for all added <target, output> pairs."""
  
      # To handle the case where the batch contains only a single class, fall back
      # to an empty metric value for that point rather than raising an exception.
      def try_with_default(func, default_retval=None):
          try:
              return func()
          except ValueError as e:
              logging.warn("Failed to compute metrics: %r", e)
          return default_retval if default_retval is not None else {}
  
      metrics = {}
      # pylint: disable=g-long-lambda
      if "chrom_f1" in self.global_metrics:
          metrics.update(
              try_with_default(
                  lambda: chrom_f1_score(
                      target=self.batches[0], prediction=self.batches[1]
                  )
              )
          )
      if "chrom_recall" in self.global_metrics:
          metrics.update(
              try_with_default(
                  lambda: chrom_recall(
                      target=self.batches[0], prediction=self.batches[1]
                  )
              )
          )
      if "chrom_precision" in self.global_metrics:
          metrics.update(
              try_with_default(
                  lambda: chrom_precision(
                      target=self.batches[0], prediction=self.batches[1]
                  )
              )
          )
      if "chrom_roc_auc_score" in self.global_metrics:
          metrics.update(
              try_with_default(
                  lambda: chrom_roc_auc_score(
                      target=self.batches[0], prediction=self.batches[1]
                  )
              )
          )
      if "chrom_specificity" in self.global_metrics:
          metrics.update(
              try_with_default(
                  lambda: chrom_specificity(
                      target=self.batches[0], prediction=self.batches[1]
                  )
              )
          )
      if "chrom_auc_pr_score" in self.global_metrics:
          metrics.update(
              try_with_default(
                  lambda: chrom_auc_pr_score(
                      target=self.batches[0], prediction=self.batches[1]
                  )
              )
          )
      if clear_annotations:
          self.clear()
      # pylint: enable=g-long-lambda
      return metrics
  
file_path: scenic/scenic/projects/tasseo/train_utils.py
imports: from typing import Any, Dict, List, Optional
  from absl import logging
  import numpy
  import sklearn.metrics
label_desc: Use image node_id 3 for calling the TasseoGlobalEvaluator obj's underlying member method code with example usage: obj.compute_metrics(clear_annotations) and returns: metrics, unknown, func