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 __init__(self, *args: Any, **kwargs: Any) -> None:
      self._warmup_steps: int = kwargs.pop("warmup_steps")
      super().__init__(*args, **kwargs)
      self._add_state(
          NUM_EXAMPLES,
          torch.zeros(self._n_tasks, dtype=torch.long),
          add_window_state=True,
          dist_reduce_fx="sum",
          persistent=True,
      )
      self._add_state(
          WARMUP_EXAMPLES,
          torch.zeros(self._n_tasks, dtype=torch.long),
          add_window_state=False,
          dist_reduce_fx="sum",
          persistent=True,
      )
      self._add_state(
          TIME_LAPSE,
          torch.zeros(self._n_tasks, dtype=torch.double),
          add_window_state=True,
          dist_reduce_fx=_max_reduction,
          persistent=True,
      )
      self._previous_ts = 0
      self._steps = 0
  
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 1 to create a new TowerQPSMetricComputation object from inherited base classes: RecMetricComputation with example: obj = TowerQPSMetricComputation()