code: def _get_states(
      labels: torch.Tensor,
      predictions: torch.Tensor,
      weights: torch.Tensor,
  ) -> Dict[str, torch.Tensor]:
      return {
          "weighted_sum": (predictions * weights).sum(dim=-1),
          "weighted_num_samples": weights.sum(dim=-1),
      }
  
file_path: torchrec/torchrec/metrics/tests/test_weighted_avg.py
imports: import unittest
  from typing import Dict, Iterable, Optional, Type, Union
  import torch
  from torchrec.metrics.rec_metric import RecComputeMode, RecMetric, RecTaskInfo
  from torchrec.metrics.test_utils import metric_test_helper, rec_metric_value_test_launcher, TestMetric
  from torchrec.metrics.weighted_avg import get_mean, WeightedAvgMetric
label_desc: Use image node_id 1 for calling the TestWeightedAvgMetric obj's underlying member method code with example usage: obj._get_states(labels, predictions, weights) and returns: dict