code: def __init__(self, *args: Any, **kwargs: Any) -> None:
      super().__init__(*args, **kwargs)
      self._add_state(
          "weighted_sum",
          torch.zeros(self._n_tasks, dtype=torch.double),
          add_window_state=True,
          dist_reduce_fx="sum",
          persistent=True,
      )
      self._add_state(
          "weighted_num_samples",
          torch.zeros(self._n_tasks, dtype=torch.double),
          add_window_state=True,
          dist_reduce_fx="sum",
          persistent=True,
      )
  
file_path: torchrec/torchrec/metrics/weighted_avg.py
imports: from typing import Any, cast, Dict, List, Optional, Type
  import torch
  from torchrec.metrics.metrics_namespace import MetricName, MetricNamespace, MetricPrefix
  from torchrec.metrics.rec_metric import MetricComputationReport, RecMetric, RecMetricComputation
label_desc: Use image node_id 1 to create a new WeightedAvgMetricComputation object from inherited base classes: RecMetricComputation with example: obj = WeightedAvgMetricComputation()