class_docstr: While profiling autograd operations, this class will add labels for module names around the forward function.
  
  The Lightning PyTorch Profiler will activate this feature automatically. It can be deactivated as follows:
  
  Example::
      from lightning.pytorch.profilers import PyTorchProfiler
      profiler = PyTorchProfiler(record_module_names=False)
      Trainer(profiler=profiler)
  
  It can be used outside of Lightning as follows:
  
  Example::
      from lightning.pytorch import Trainer, seed_everything
      with RegisterRecordFunction(model):
          out = model(batch)
class_docstr_tok: ["While","profiling","autograd","operations",",","this","class","will","add","labels","for","module","names","around","the","forward","function",".","The","Lightning","PyTorch","Profiler","will","activate","this","feature","automatically",".","It","can","be","deactivated","as","follows",":","Example",":",":","from","lightning.pytorch.profilers","import","PyTorchProfiler","profiler","=","PyTorchProfiler","(","record_module_names=False",")","Trainer","(","profiler=profiler",")","It","can","be","used","outside","of","Lightning","as","follows",":","Example",":",":","from","lightning.pytorch","import","Trainer",",","seed_everything","with","RegisterRecordFunction","(","model",")",":","out","=","model","(","batch",")"]
code: def __exit__(self, type: Any, value: Any, traceback: Any) -> None:
      for handles in self._handles.values():
          for h in handles:
              h.remove()
      self._handles = {}
  
imports: import inspect
  import logging
  import os
  from functools import lru_cache, partial
  from pathlib import Path
  from typing import TYPE_CHECKING, Any, Callable, ContextManager, Dict, List, Optional, Type, Union
  import torch
  from torch import Tensor, nn
  from torch.autograd.profiler import EventList, record_function
  from torch.profiler import ProfilerAction, ProfilerActivity, tensorboard_trace_handler
  from torch.utils.hooks import RemovableHandle
  from typing_extensions import override
  from lightning.fabric.accelerators.cuda import is_cuda_available
  from lightning.pytorch.profilers.profiler import Profiler
  from lightning.pytorch.utilities.exceptions import MisconfigurationException
  from lightning.pytorch.utilities.rank_zero import WarningCache, rank_zero_warn
label_desc: Use image node_id 5 for calling the RegisterRecordFunction obj's underlying member method code with example usage: obj.__exit__(type, value, traceback) without return types