code: def _average_metric(
      preds: Tensor, target: Tensor, metric_func: Callable
  ) -> Tensor:
      """Average the metric values.
  
      Args:
          preds: predictions, shape[batch, spk, time]
          target: targets, shape[batch, spk, time]
          metric_func: a function which return best_metric and best_perm
  
      Returns:
          the average of best_metric
  
      """
      return metric_func(preds, target)[0].mean()
  
imports: from functools import partial
  from typing import Callable, Tuple
  import numpy
  import pytest
  import torch
  from scipy.optimize import linear_sum_assignment
  from torch import Tensor
  from torchmetrics.audio import PermutationInvariantTraining
  from torchmetrics.functional.audio import permutation_invariant_training, scale_invariant_signal_distortion_ratio, signal_noise_ratio
  from torchmetrics.functional.audio.pit import _find_best_perm_by_exhaustive_method, _find_best_perm_by_linear_sum_assignment
  from unittests import BATCH_SIZE, NUM_BATCHES, _Input
  from unittests.helpers import seed_all
  from unittests.helpers.testers import MetricTester
label_desc: Use image node_id 2 for calling a global function with example usage: _average_metric(preds, target, metric_func) and returns: metric_func