class_docstr: TowerQPSMetric defines the tower QPS metric.
  Tower QPS's formula is training example count / time
  where training example count  = sum(examples for trainer 1, ... examples for trainer n)
  and time = max(time for trainer 1, ... time for trainer n)
  It's mostly used for cases where there's no fixed batch size
  For example for Pyper MTML models, given the same input, different tasks may have
  different numbers of examples to process
  
  Args:
      world_size (int): the number of trainers.
      my_rank (int): the rank of this trainer.
      batch_size (int): batch size used by this trainer.
      tasks (List[RecTaskInfo]): the information of the model tasks.
      compute_mode (RecComputeMode): the computation mode. See RecComputeMode.
      window_size (int): the window size for the window metric.
      fused_update_limit (int): the maximum number of updates to be fused.
      process_group (Optional[ProcessGroup]): the process group used for the
          communication. Will use the default process group if not specified.
  
  Call Args:
      Not supported.
  
  Returns:
      Not supported.
  
  Example::
  
      For world_size = 4, suppose we have 1 step after warmup
      predictions = [
          [0.8033, 0.0662, 0.7559],
          [0.1821, 0.9652, 0.4602],
          [0.8545, 0.4758, 0.2220],
          [0.1021, 0.2469, 0.7259],
      ],
      previous_ts = [278.94, 312.16, 286.96, 291.43]
      ts = [281.35, 316.45, 289.47, 295.55]
  
      num_examples = [3, 3, 3, 3]
      time_lapse = [2.41, 4.29, 2.51, 4.12]
  
      tower_qps = torch.sum(num_examples) / torch.max(time_lapse) = 2.80
class_docstr_tok: ["TowerQPSMetric","defines","the","tower","QPS","metric",".","Tower","QPS","'s","formula","is","training","example","count","\/","time","where","training","example","count","=","sum","(","examples","for","trainer","1",",","...","examples","for","trainer","n",")","and","time","=","max","(","time","for","trainer","1",",","...","time","for","trainer","n",")","It","'s","mostly","used","for","cases","where","there","'s","no","fixed","batch","size","For","example","for","Pyper","MTML","models",",","given","the","same","input",",","different","tasks","may","have","different","numbers","of","examples","to","process","Args",":","world_size","(","int",")",":","the","number","of","trainers",".","my_rank","(","int",")",":","the","rank","of","this","trainer",".","batch_size","(","int",")",":","batch","size","used","by","this","trainer",".","tasks","(","List","[","RecTaskInfo","]",")",":","the","information","of","the","model","tasks",".","compute_mode","(","RecComputeMode",")",":","the","computation","mode",".","See","RecComputeMode",".","window_size","(","int",")",":","the","window","size","for","the","window","metric",".","fused_update_limit","(","int",")",":","the","maximum","number","of","updates","to","be","fused",".","process_group","(","Optional","[","ProcessGroup","]",")",":","the","process","group","used","for","the","communication",".","Will","use","the","default","process","group","if","not","specified",".","Call","Args",":","Not","supported",".","Returns",":","Not","supported",".","Example",":",":","For","world_size","=","4",",","suppose","we","have","1","step","after","warmup","predictions","=","[","[","0.8033",",","0.0662",",","0.7559","]",",","[","0.1821",",","0.9652",",","0.4602","]",",","[","0.8545",",","0.4758",",","0.2220","]",",","[","0.1021",",","0.2469",",","0.7259","]",",","]",",","previous_ts","=","[","278.94",",","312.16",",","286.96",",","291.43","]","ts","=","[","281.35",",","316.45",",","289.47",",","295.55","]","num_examples","=","[","3",",","3",",","3",",","3","]","time_lapse","=","[","2.41",",","4.29",",","2.51",",","4.12","]","tower_qps","=","torch.sum","(","num_examples",")","\/","torch.max","(","time_lapse",")","=","2.80"]
code: def __init__(
      self,
      world_size: int,
      my_rank: int,
      batch_size: int,
      tasks: List[RecTaskInfo],
      compute_mode: RecComputeMode = RecComputeMode.UNFUSED_TASKS_COMPUTATION,
      window_size: int = 100,
      fused_update_limit: int = 0,
      process_group: Optional[dist.ProcessGroup] = None,
      warmup_steps: int = WARMUP_STEPS,
      **kwargs: Any,
  ) -> None:
      if fused_update_limit > 0:
          raise RecMetricException(
              "Fused update is not supported for tower QPS"
          )
  
      kwargs["warmup_steps"] = warmup_steps
  
      super().__init__(
          world_size=world_size,
          my_rank=my_rank,
          batch_size=batch_size,
          tasks=tasks,
          compute_mode=compute_mode,
          window_size=window_size,
          fused_update_limit=fused_update_limit,
          process_group=process_group,
          **kwargs,
      )
  
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 TowerQPSMetric object from inherited base classes: RecMetric with example: obj = TowerQPSMetric(world_size, my_rank, batch_size, tasks, compute_mode, window_size, fused_update_limit, process_group, warmup_steps)