class_docstr: This class implements the RecMetricComputation for tower QPS.
  
  The constructor arguments are defined in RecMetricComputation.
  See the docstring of RecMetricComputation for more detail.
class_docstr_tok: ["This","class","implements","the","RecMetricComputation","for","tower","QPS",".","The","constructor","arguments","are","defined","in","RecMetricComputation",".","See","the","docstring","of","RecMetricComputation","for","more","detail","."]
code: def update(
      self,
      *,
      predictions: Optional[torch.Tensor],
      labels: torch.Tensor,
      weights: Optional[torch.Tensor],
      **kwargs: Dict[str, Any],
  ) -> None:
      self._steps += 1
      num_examples_scalar = labels.shape[-1]
      num_examples = torch.tensor(num_examples_scalar, dtype=torch.long)
      self_num_examples = getattr(self, NUM_EXAMPLES)
      self_num_examples += num_examples
      ts = time.monotonic()
      if self._steps <= self._warmup_steps:
          self_warmup_examples = getattr(self, WARMUP_EXAMPLES)
          self_warmup_examples += num_examples
          if self._steps == self._warmup_steps:
              self._previous_ts = ts
      else:
          self._aggregate_window_state(
              NUM_EXAMPLES, num_examples, num_examples_scalar
          )
          time_lapse = torch.tensor(
              ts - self._previous_ts, dtype=torch.double
          )
          self_time_lapse = getattr(self, TIME_LAPSE)
          self_time_lapse += time_lapse
          self._aggregate_window_state(
              TIME_LAPSE, time_lapse, num_examples_scalar
          )
          self._previous_ts = ts
  
file_path: torchrec/torchrec/metrics/tower_qps.py
imports: import time
  from typing import Any, cast, Dict, List, Optional, Type
  import torch
  import torch.distributed
  from torchrec.metrics.metrics_config import RecComputeMode, RecTaskInfo
  from torchrec.metrics.metrics_namespace import MetricName, MetricNamespace, MetricPrefix
  from torchrec.metrics.rec_metric import MetricComputationReport, RecMetric, RecMetricComputation, RecMetricException, RecModelOutput
label_desc: Use image node_id 2 for calling the TowerQPSMetricComputation obj's underlying member method code with example usage: obj.update() without return types