code: def test_performance(
      repo, values, run_opts, updates_dir=None, recipe_overrides={}
  ):
      """Runs the evaluation partition of a recipe dataset for a pretrained model.
  
      Parameters
      ----------
      repo: str
          Source of pretrained model (assuming its within the HF speechbrain collection).
      values: dict
          Interface specification.
          Examples: speechbrain:hf-interface-testing/updates_pretrained_models/ssl-wav2vec2-base-librispeech/test.yaml
                    speechbrain:hf-interface-testing/updates_pretrained_models/asr-wav2vec2-librispeech/test.yaml
      run_opts: dict
          Run options, such as device
      updates_dir: str
          Controls whether/not we are in the refactored results (None: expected results; before refactoring).
      recipe_overrides: dict
          Recipe YAMLs contain placeholders and flags which need to be overwritten (e.g. data_folder & skip_prep).
          See: overrides.yaml
  
      Returns
      -------
      Dict for export to yaml with performance statistics, as specified in the test.yaml files.
      """
      # Dataset depending file structure
      tmp_dir = f'tests/tmp/{values["dataset"]}'
      speechbrain.create_experiment_directory(
          experiment_directory=tmp_dir
      )
      stats_meta = {
          f'[{values["dataset"]}] - {"BEFORE" if updates_dir is None else "AFTER"}': repo
      }
  
      # Load pretrained
      model = get_model(
          repo=repo,
          values=values,
          updates_dir=updates_dir,
          run_opts=run_opts,
      )  # noqa
  
      # Dataio preparation; we need the test sets only
      with open(values["recipe_yaml"]) as fin:
          recipe_hparams = load_hyperpyyaml(
              fin, values["overrides"] | recipe_overrides
          )
  
      # Dataset preparation is assumed to be done through recipes; before running this.
      exec(values["dataio"])
      test_datasets = deepcopy(eval(values["test_datasets"]))
  
      # harmonise
      if type(test_datasets) is not dict:
          tmp = {}
          if type(test_datasets) is list:
              for i, x in enumerate(test_datasets):
                  tmp[i] = x
          else:
              tmp[0] = test_datasets
          test_datasets = tmp
  
      # prepare testing
      logger = FileTrainLogger(save_file=f"{tmp_dir}/{repo}.log")
      reporting = deepcopy(values["performance"])
      for metric, specs in reporting.items():
          reporting[metric]["tracker"] = deepcopy(
              recipe_hparams[specs["handler"]]()
          )
  
      test_loader_kwargs = deepcopy(
          recipe_hparams[values["test_loader"]]
      )
      del recipe_hparams
  
      stats = {}
      for (
          k
      ) in test_datasets.keys():  # keys are test_clean, test_other etc
          test_set = test_datasets[k]
          if not (
              isinstance(test_set, DataLoader)
              or isinstance(test_set, LoopedLoader)
          ):
              test_set = make_dataloader(test_set, **test_loader_kwargs)
  
          with torch.no_grad():
              for batch in tqdm(
                  test_set, dynamic_ncols=True, disable=False
              ):
                  batch = batch.to(model.device)
                  wavs, wav_lens = batch.sig
                  wavs, wav_lens = (  # noqa
                      wavs.to(model.device),
                      wav_lens.to(model.device),
                  )
                  predictions = eval(  # noqa
                      f'model.{values["fnx"]}(wavs, wav_lens)'
                  )
                  predicted = eval(values["predicted"])  # noqa
                  targeted = eval(values["targeted"])  # noqa
                  ids = batch.id  # noqa
                  for metric in reporting.keys():
                      reporting[metric]["tracker"].append(
                          *eval(values["to_stats"])
                      )
  
          stats[k] = {}
          for metric, specs in reporting.items():
              stats[k][metric] = specs["tracker"].summarize(
                  specs["field"]
              )
          logger.log_stats(
              stats_meta=stats_meta | {"set": k},
              test_stats=stats[k],
          )
  
      return stats
  
imports: import os
  import sys
  from tqdm import tqdm
  import yaml
  import torch
  import importlib
  import subprocess
  import speechbrain
  from glob import glob
  from copy import deepcopy
  from torch.utils.data import DataLoader
  from hyperpyyaml import load_hyperpyyaml
  from speechbrain.utils.distributed import run_on_main
  from speechbrain.utils.train_logger import FileTrainLogger
  from speechbrain.inference.interfaces import foreign_class
  from speechbrain.dataio.dataloader import LoopedLoader, make_dataloader
label_desc: Use image node_id 6 for calling a global function with example usage: test_performance(repo, values, run_opts, updates_dir, recipe_overrides) and returns: stats