class_docstr: Accumulate stats (from timers) over many iterations
class_docstr_tok: ["Accumulate","stats","(","from","timers",")","over","many","iterations"]
code: def __init__(self, use_cuda_events=True):
      self._host_stats: Mapping[str, PerfMetric] = defaultdict(
          PerfMetric
      )
      self._cuda_stats: Mapping[str, PerfMetric] = defaultdict(
          PerfMetric
      )
  
      if use_cuda_events:
          if torch.cuda.is_available():
              self._cuda_pending_timers = deque(
                  maxlen=PerfStats.MAX_PENDING_TIMERS
              )
          else:
              logging.warning(
                  "CUDA unavailable: CUDA events are not logged."
              )
              self._cuda_pending_timers = None
      else:
          self._cuda_pending_timers = None
  
imports: import logging
  from collections import defaultdict, deque
  from time import perf_counter
  from typing import List, Mapping, Optional, Tuple
  import torch
  from torch.cuda import Event
label_desc: Use image node_id 1 to create a new PerfStats object  with example: obj = PerfStats(use_cuda_events)