code: def _average_metric(
      preds, target, metric_func, **kwargs: Dict[str, Any]
  ):
      # shape: preds [BATCH_SIZE, 1, Time] , target [BATCH_SIZE, 1, Time]
      # or shape: preds [NUM_BATCHES*BATCH_SIZE, 1, Time] , target [NUM_BATCHES*BATCH_SIZE, 1, Time]
      return metric_func(preds, target, **kwargs).mean()
  
imports: from functools import partial
  from typing import Any, Dict
  import pytest
  import torch
  from srmrpy import srmr
  from torch import Tensor
  from torchmetrics.audio.srmr import SpeechReverberationModulationEnergyRatio
  from torchmetrics.functional.audio.srmr import speech_reverberation_modulation_energy_ratio
  from torchmetrics.utilities.imports import _TORCHAUDIO_GREATER_EQUAL_0_10
  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