class_docstr: Test class for `HitRate` metric.
class_docstr_tok: ["Test","class","for","`","HitRate","`","metric","."]
docstr: Test class implementation of metric.
docstr_tok: ["Test","class","implementation","of","metric","."]
code: def test_class_metric(
      self,
      ddp: bool,
      indexes: Tensor,
      preds: Tensor,
      target: Tensor,
      empty_target_action: str,
      ignore_index: int,
      k: int,
      aggregation: Union[
          Literal["mean", "median", "min", "max"], Callable
      ],
  ):
      """Test class implementation of metric."""
      metric_args = {
          "empty_target_action": empty_target_action,
          "top_k": k,
          "ignore_index": ignore_index,
          "aggregation": aggregation,
      }
  
      self.run_class_metric_test(
          ddp=ddp,
          indexes=indexes,
          preds=preds,
          target=target,
          metric_class=RetrievalHitRate,
          reference_metric=_hit_rate_at_k,
          metric_args=metric_args,
      )
  
file_path: torchmetrics/tests/unittests/retrieval/test_hit_rate.py
imports: from typing import Callable, Optional, Union
  import numpy
  import pytest
  from torch import Tensor
  from torchmetrics.functional.retrieval.hit_rate import retrieval_hit_rate
  from torchmetrics.retrieval.hit_rate import RetrievalHitRate
  from typing_extensions import Literal
  from unittests.helpers import seed_all
  from unittests.retrieval.helpers import RetrievalMetricTester, _concat_tests, _custom_aggregate_fn, _default_metric_class_input_arguments, _default_metric_class_input_arguments_ignore_index, _default_metric_functional_input_arguments, _errors_test_class_metric_parameters_default, _errors_test_class_metric_parameters_k, _errors_test_class_metric_parameters_no_pos_target, _errors_test_functional_metric_parameters_default, _errors_test_functional_metric_parameters_k
label_desc: Use image node_id 1 for calling the TestHitRate obj's underlying member method code with example usage: obj.test_class_metric(ddp, indexes, preds, target, empty_target_action, ignore_index, k, aggregation) without return types