code: def _reduce(
      states: Dict[str, List[torch.Tensor]]
  ) -> Dict[str, torch.Tensor]:
      reduced_states: Dict[str, torch.Tensor] = {}
      # Need to check if states is empty, because we only update the states after warmup
      if states:
          reduced_states["num_samples"] = torch.sum(
              torch.stack(states["num_samples"]), dim=0
          )
          reduced_states["time_lapse"] = torch.max(
              torch.stack(states["time_lapse"]), dim=0
          ).values
      return reduced_states
  
imports: import unittest
  from functools import partial, update_wrapper
  from typing import Callable, Dict, List, Optional, Tuple, Type
  import torch
  import torch.distributed
  from torchrec.metrics.metrics_config import DefaultTaskInfo
  from torchrec.metrics.model_utils import parse_task_model_outputs
  from torchrec.metrics.rec_metric import RecComputeMode, RecMetric, RecTaskInfo
  from torchrec.metrics.test_utils import gen_test_batch, gen_test_tasks, metric_test_helper, rec_metric_value_test_launcher, TestMetric
  from torchrec.metrics.tower_qps import TowerQPSMetric
label_desc: Use image node_id 3 for calling the TestTowerQPSMetric obj's underlying member method code with example usage: obj._reduce(states) and returns: reduced_states