class_docstr: Context manager/function decorator that adds a label to a code block/function when running autograd profiler.
  
  It is useful when tracing the code profile.
  
  Args:
      name (str): Label assigned to the block of code.
      node_id (int): ID of node, for distributed profiling. Unset in
      non-distributed cases.
  
  Example:
      >>> # xdoctest: +REQUIRES(env:TORCH_DOCTEST_AUTOGRAD_PROFILER)
      >>> x = torch.randn((1, 1), requires_grad=True)
      >>> with torch.autograd.profiler.profile() as prof:
      ...     y = x ** 2
      ...     with torch.autograd.profiler.record_function("label-z"): # label the block
      ...         z = y ** 3
      ...     y.backward()
      ...
      >>> # xdoctest: +IGNORE_WANT
      >>> # NOTE: some columns were removed for brevity
      >>> print(prof.key_averages().table(sort_by="self_cpu_time_total"))
      -----------------------------------  ---------------  ---------------  ---------------
      Name                                 Self CPU total %  CPU time avg     Number of Calls
      -----------------------------------  ---------------  ---------------  ---------------
      pow                                  60.77%           47.470us         3
      mul                                  21.73%           25.465us         2
      PowBackward0                         12.03%           121.891us        1
      torch::autograd::AccumulateGrad      2.70%            6.324us          1
      label-z                              2.13%            12.421us         1
      torch::autograd::GraphRoot           0.64%            1.503us          1
      -----------------------------------  ---------------  ---------------  ---------------
      Self CPU time total: 234.344us
      CUDA time total: 0.000us
code: def __init__(self, name: str, args: Optional[str] = None):
      self.name: str = name
      self.args: Optional[str] = args
      # Whether or not we should run record function's end callbacks when exiting.
      self.run_callbacks_on_exit: bool = True
      # TODO: TorchScript ignores standard type annotation here
      # self.record: Optional["torch.classes.profiler._RecordFunction"] = None
      self.record = torch.jit.annotate(
          Optional["torch.classes.profiler._RecordFunction"], None
      )
  
imports: from collections import defaultdict
  from typing import Any, Dict, List, Optional
  from warnings import warn
  import torch
  import torch.cuda
  from torch._C import _get_privateuse1_backend_name
  from torch._C._profiler import _ExperimentalConfig
  from torch.autograd import _disable_profiler, _enable_profiler, _kineto_step, _prepare_profiler, _ProfilerResult, _supported_activities, DeviceType, kineto_available, ProfilerActivity, ProfilerConfig, ProfilerState
  from torch.autograd.profiler_util import _filter_name, _filter_stack_entry, _rewrite_name, EventList, FunctionEvent, MEMORY_EVENT_NAME, MemRecordsAcc, OUT_OF_MEMORY_EVENT_NAME
  from torch.futures import Future
label_desc: Use image node_id 1 to create a new record_function object from inherited base classes: _ContextDecorator with example: obj = record_function(name, args)