code: def update(
      self,
      *,
      predictions: Optional[torch.Tensor],
      labels: torch.Tensor,
      weights: Optional[torch.Tensor],
      **kwargs: Dict[str, Any],
  ) -> None:
      num_samples = labels.shape[0]
      predictions = cast(torch.Tensor, predictions)
      weights = cast(torch.Tensor, weights)
      states = {
          "weighted_sum": (predictions * weights).sum(dim=-1),
          "weighted_num_samples": weights.sum(dim=-1),
      }
      for state_name, state_value in states.items():
          state = getattr(self, state_name)
          state += state_value
          self._aggregate_window_state(
              state_name, state_value, num_samples
          )
  
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 2 for calling the WeightedAvgMetricComputation obj's underlying member method code with example usage: obj.update() without return types