class_docstr: Accumulate stats (from timers) over many iterations
class_docstr_tok: ["Accumulate","stats","(","from","timers",")","over","many","iterations"]
docstr: Service pending timers. Dequeue timers and aggregate Cuda time intervals,
  until the first "pending" timer (i.e. dependent on a not-yet-ready cuda event).
docstr_tok: ["Service","pending","timers",".","Dequeue","timers","and","aggregate","Cuda","time","intervals",",","until","the","first","``","pending","''","timer","(","i.e",".","dependent","on","a","not-yet-ready","cuda","event",")","."]
code: def _process_cuda_events(self):
      """
      Service pending timers. Dequeue timers and aggregate Cuda time intervals,
      until the first "pending" timer (i.e. dependent on a not-yet-ready cuda event).
      """
      while len(self._cuda_pending_timers) > 0:
          timer = self._cuda_pending_timers[0]
          elapsed_cuda = 0.0
  
          for ev_start, ev_end in timer._cuda_event_intervals:
              if not ev_start.query() or not ev_end.query():
                  # Cuda events associated with this timer aren't ready yet,
                  # stop servicing the queue.
                  return
              # Use seconds (instead of ms) for consistency with "host" timers
              elapsed_cuda += ev_start.elapsed_time(ev_end) / 1000.0
  
          # All time intervals for this timer are now accounted for.
          # Aggregate stats and pop from pending queue.
          self._cuda_stats[timer.name].update(elapsed_cuda)
          self._cuda_pending_timers.popleft()
  
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 3 for calling the PerfStats obj's underlying member method code with example usage: obj._process_cuda_events() without return types