code: def _errors_test_class_metric(
      indexes: Tensor,
      preds: Tensor,
      target: Tensor,
      metric_class: Metric,
      message: str = "",
      metric_args: Optional[dict] = None,
      exception_type: Type[Exception] = ValueError,
      kwargs_update: Optional[dict] = None,
  ):
      """Check types, parameters and errors.
  
      Args:
          indexes: torch tensor with indexes
          preds: torch tensor with predictions
          target: torch tensor with targets
          metric_class: metric class that should be tested
          message: message that exception should return
          metric_args: arguments for class initialization
          exception_type: callable function that is used for comparison
          kwargs_update: Additional keyword arguments that will be passed with indexes, preds and
              target when running update on the metric.
  
      """
      metric_args = metric_args or {}
      kwargs_update = kwargs_update or {}
      with pytest.raises(exception_type, match=message):  # noqa: PT012
          metric = metric_class(**metric_args)
          metric(preds, target, indexes=indexes, **kwargs_update)
  
imports: from functools import partial
  from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union
  import numpy
  import pytest
  import torch
  from numpy import array
  from torch import Tensor, tensor
  from torchmetrics.retrieval.base import _retrieval_aggregate
  from typing_extensions import Literal
  from unittests.helpers import seed_all
  from unittests.helpers.testers import Metric, MetricTester
  from unittests.retrieval.inputs import _input_retrieval_scores
  from unittests.retrieval.inputs import _input_retrieval_scores_all_target
  from unittests.retrieval.inputs import _input_retrieval_scores_empty
  from unittests.retrieval.inputs import _input_retrieval_scores_extra
  from unittests.retrieval.inputs import _input_retrieval_scores_float_target
  from unittests.retrieval.inputs import _input_retrieval_scores_for_adaptive_k
  from unittests.retrieval.inputs import _input_retrieval_scores_int_target
  from unittests.retrieval.inputs import _input_retrieval_scores_mismatching_sizes
  from unittests.retrieval.inputs import _input_retrieval_scores_mismatching_sizes_func
  from unittests.retrieval.inputs import _input_retrieval_scores_no_target
  from unittests.retrieval.inputs import _input_retrieval_scores_with_ignore_index
  from unittests.retrieval.inputs import _input_retrieval_scores_wrong_targets
label_desc: Use image node_id 5 for calling a global function with example usage: _errors_test_class_metric(indexes, preds, target, metric_class, message, metric_args, exception_type, kwargs_update) without return types