class_docstr: Layer by layer profiling of PyTorch models, using the PyTorch profiler
  for memory profiling. Parts of the code are adapted from :obj:`torchprof`
  for layer-wise grouping.
  
  Args:
      model (torch.nn.Module): The underlying model to be profiled.
      enabled (bool, optional): If set to :obj:`True`, turn on the profiler.
          (default: :obj:`False`)
      use_cuda (bool, optional): Whether to profile CUDA execution.
          (default: :obj:`False`)
      profile_memory (bool, optional): If set to :obj:`True`, also profile
          memory usage. (default: :obj:`False`)
      paths ([str], optional): Pre-defined paths for fast loading.
          (default: :obj:`None`)
code: def __init__(
      self,
      model: torch.nn.Module,
      enabled: bool = True,
      use_cuda: bool = False,
      profile_memory: bool = False,
      paths: Optional[List[str]] = None,
  ):
      self._model = model
      self.enabled = enabled
      self.use_cuda = use_cuda
      self.profile_memory = profile_memory
      self.paths = paths
  
      self.entered = False
      self.exited = False
      self.traces = ()
      self._ids = set()
      self.trace_profile_events = defaultdict(list)
  
imports: import functools
  from collections import OrderedDict, defaultdict, namedtuple
  from typing import Any, List, NamedTuple, Optional, Tuple
  import torch
  import torch.profiler
label_desc: Use image node_id 1 to create a new Profiler object  with example: obj = Profiler(model, enabled, use_cuda, profile_memory, paths)