code: def _init_profiler(
      trainer: "pl.Trainer", profiler: Optional[Union[Profiler, str]]
  ) -> None:
      if isinstance(profiler, str):
          PROFILERS = {
              "simple": SimpleProfiler,
              "advanced": AdvancedProfiler,
              "pytorch": PyTorchProfiler,
              "xla": XLAProfiler,
          }
          profiler = profiler.lower()
          if profiler not in PROFILERS:
              raise MisconfigurationException(
                  "When passing string value for the `profiler` parameter of `Trainer`,"
                  f" it can only be one of {list(PROFILERS.keys())}"
              )
          profiler_class = PROFILERS[profiler]
          profiler = profiler_class()
      trainer.profiler = profiler or PassThroughProfiler()
  
file_path: pytorch-lightning/src/lightning/pytorch/trainer/setup.py
imports: from typing import Optional, Union
  import lightning.pytorch
  from lightning.fabric.utilities.warnings import PossibleUserWarning
  from lightning.pytorch.accelerators import CUDAAccelerator, MPSAccelerator, XLAAccelerator
  from lightning.pytorch.loggers.logger import DummyLogger
  from lightning.pytorch.profilers import AdvancedProfiler, PassThroughProfiler, Profiler, PyTorchProfiler, SimpleProfiler, XLAProfiler
  from lightning.pytorch.utilities.exceptions import MisconfigurationException
  from lightning.pytorch.utilities.imports import _graphcore_available_and_importable, _habana_available_and_importable
  from lightning.pytorch.utilities.rank_zero import rank_zero_info, rank_zero_warn
label_desc: Use image node_id 3 for calling a global function with example usage: _init_profiler(trainer, profiler) without return types