code: def stop(self, action_name: str) -> None:
      if action_name in self._recording_map:
          self._recording_map[action_name].__exit__(None, None, None)
          del self._recording_map[action_name]
  
      if not _KINETO_AVAILABLE or self._emit_nvtx:
          return
  
      if self.profiler is not None and any(
          action_name.endswith(func) for func in self.STEP_FUNCTIONS
      ):
          assert isinstance(self.profiler, torch.profiler.profile)
          if self._schedule is not None:
              self._schedule.pre_step(action_name)
  
          # the default schedule requires a minimum of 5 steps to properly work: `wait=1, warmup=1, active=3`.
          # otherwise, this will raise a `segmentation fault`.
          if self._should_override_schedule():
              warning_cache.warn(
                  "The PyTorch Profiler default schedule will be overridden as there is not enough "
                  "steps to properly record traces."
              )
              self._schedule = None
              self.profiler.schedule = (
                  torch.profiler.profiler._default_schedule_fn
              )
  
          def on_trace_ready(profiler: _PROFILER) -> None:
              if self.dirpath is not None:
                  if self._export_to_chrome:
                      handler = tensorboard_trace_handler(
                          str(self.dirpath),
                          self._prepare_filename(
                              action_name=action_name, extension=""
                          ),
                      )
                      handler(profiler)
  
                  if self._export_to_flame_graph:
                      path = os.path.join(
                          self.dirpath,
                          self._prepare_filename(
                              action_name=action_name,
                              extension=".stack",
                          ),
                      )
                      assert isinstance(
                          profiler, torch.autograd.profiler.profile
                      )
                      profiler.export_stacks(path, metric=self._metric)
              else:
                  rank_zero_warn(
                      "The PyTorchProfiler failed to export trace as `dirpath` is None"
                  )
  
          if not self._has_on_trace_ready:
              self.profiler.on_trace_ready = on_trace_ready
  
          if self._schedule is not None:
              self.profiler.step_num = self._schedule.num_step
          self.profiler.step()
          self.profiler.add_metadata("Framework", "pytorch-lightning")
  
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 8 for calling the PyTorchProfiler obj's underlying member method code with example usage: obj.stop(action_name) without return types