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
docstr: Use for profiling async calls that return a future.
  
  Calling this function will extend recording beyond this scope, until the future is
  satisfied. It is useful for profiling the end to end time of asynchronous calls.
  This function should only be called once to attach the callback onto the future, and
  will throw if called multiple times.
  
  Args:
      fut: (torch._C.Future): future for which to schedule
      callback for.
  
  Returns:
      A future that completes with the value of the passed in future when
      the profiling callbacks have ran.
docstr_tok: ["Use","for","profiling","async","calls","that","return","a","future",".","Calling","this","function","will","extend","recording","beyond","this","scope",",","until","the","future","is","satisfied",".","It","is","useful","for","profiling","the","end","to","end","time","of","asynchronous","calls",".","This","function","should","only","be","called","once","to","attach","the","callback","onto","the","future",",","and","will","throw","if","called","multiple","times",".","Args",":","fut",":","(","torch._C.Future",")",":","future","for","which","to","schedule","callback","for",".","Returns",":","A","future","that","completes","with","the","value","of","the","passed","in","future","when","the","profiling","callbacks","have","ran","."]
code: def _call_end_callbacks_on_future(
      self, fut: Future[Any]
  ) -> Future[Any]:
      """Use for profiling async calls that return a future.
  
      Calling this function will extend recording beyond this scope, until the future is
      satisfied. It is useful for profiling the end to end time of asynchronous calls.
      This function should only be called once to attach the callback onto the future, and
      will throw if called multiple times.
  
      Args:
          fut: (torch._C.Future): future for which to schedule
          callback for.
  
      Returns:
          A future that completes with the value of the passed in future when
          the profiling callbacks have ran.
  
      """
      # Throw if we have already attached a callback onto the future.
      if not self.run_callbacks_on_exit:
          raise RuntimeError(
              "_call_end_callbacks_on_future can only be called once."
          )
  
      # We are scheduling to run this RecordFunction's end callbacks when the
      # passed in future completes, so don't run end callbacks on exit.
      self.run_callbacks_on_exit = False
  
      # Local variable is needed by TorchScript to refine Optional[T] to T
      record = self.record
      assert record is not None
  
      # TODO: Too slow with __torch_function__ handling enabled
      # See https://github.com/pytorch/pytorch/issues/76410
      if not torch.jit.is_scripting():
          with torch._C.DisableTorchFunctionSubclass():
              profiled_future = torch.ops.profiler._call_end_callbacks_on_jit_fut._RecordFunction(
                  record, fut
              )
      else:
          profiled_future = (
              torch.ops.profiler._call_end_callbacks_on_jit_fut(
                  record, fut
              )
          )
      return profiled_future
  
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 4 for calling the record_function obj's underlying member method code with example usage: obj._call_end_callbacks_on_future(fut) and returns: profiled_future