class_docstr: This set of tests verify the computation logic of accuracy with a modified threshold
  in several cases that we know the computation results.
class_docstr_tok: ["This","set","of","tests","verify","the","computation","logic","of","accuracy","with","a","modified","threshold","in","several","cases","that","we","know","the","computation","results","."]
code: def _test_accuracy_helper(
      self,
      labels: torch.Tensor,
      predictions: torch.Tensor,
      weights: torch.Tensor,
      expected_accuracy: torch.Tensor,
      threshold: float,
  ) -> None:
      num_task = labels.shape[0]
      batch_size = labels.shape[0]
      task_list = []
      inputs: Dict[
          str, Union[Dict[str, torch.Tensor], torch.Tensor]
      ] = {
          "predictions": {},
          "labels": {},
          "weights": {},
      }
      for i in range(num_task):
          task_info = RecTaskInfo(
              name=f"Task:{i}",
              label_name="label",
              prediction_name="prediction",
              weight_name="weight",
          )
          task_list.append(task_info)
          # pyre-ignore
          inputs["predictions"][task_info.name] = predictions[i]
          # pyre-ignore
          inputs["labels"][task_info.name] = labels[i]
          # pyre-ignore
          inputs["weights"][task_info.name] = weights[i]
  
      accuracy = AccuracyMetric(
          world_size=1,
          my_rank=0,
          batch_size=batch_size,
          tasks=task_list,
          # pyre-ignore
          threshold=threshold,  # threshold is one of the kwargs
      )
      # pyre-ignore
      accuracy.update(**inputs)
      actual_accuracy = accuracy.compute()
  
      for task_id, task in enumerate(task_list):
          cur_actual_accuracy = actual_accuracy[
              f"accuracy-{task.name}|window_accuracy"
          ]
          cur_expected_accuracy = expected_accuracy[task_id].unsqueeze(
              dim=0
          )
  
          torch.testing.assert_close(
              cur_actual_accuracy,
              cur_expected_accuracy,
              atol=1e-4,
              rtol=1e-4,
              check_dtype=False,
              msg=f"Actual: {cur_actual_accuracy}, Expected: {cur_expected_accuracy}",
          )
  
imports: import unittest
  from typing import Dict, Iterable, Type, Union
  import torch
  from torch import no_grad
  from torchrec.metrics.accuracy import AccuracyMetric, compute_accuracy
  from torchrec.metrics.metrics_config import DefaultTaskInfo
  from torchrec.metrics.rec_metric import RecComputeMode, RecMetric
  from torchrec.metrics.test_utils import metric_test_helper, rec_metric_value_test_launcher, RecTaskInfo, TestMetric
label_desc: Use image node_id 1 for calling the ThresholdValueTest obj's underlying member method code with example usage: obj._test_accuracy_helper(labels, predictions, weights, expected_accuracy, threshold) without return types