code: def _parse_env_variables(
      cls: Type, template: str = "PL_%(cls_name)s_%(cls_argument)s"
  ) -> Namespace:
      """Parse environment arguments if they are defined.
  
      Examples:
  
          >>> from lightning.pytorch import Trainer
          >>> _parse_env_variables(Trainer)
          Namespace()
          >>> import os
          >>> os.environ["PL_TRAINER_DEVICES"] = '42'
          >>> os.environ["PL_TRAINER_BLABLABLA"] = '1.23'
          >>> _parse_env_variables(Trainer)
          Namespace(devices=42)
          >>> del os.environ["PL_TRAINER_DEVICES"]
  
      """
      env_args = {}
      for arg_name in inspect.signature(cls).parameters:
          env = template % {
              "cls_name": cls.__name__.upper(),
              "cls_argument": arg_name.upper(),
          }
          val = os.environ.get(env)
          if not (val is None or val == ""):
              # todo: specify the possible exception
              with suppress(Exception):
                  # converting to native types like int/float/bool
                  val = literal_eval(val)
              env_args[arg_name] = val
      return Namespace(**env_args)
  
file_path: pytorch-lightning/src/lightning/pytorch/utilities/argparse.py
imports: import inspect
  import os
  from argparse import Namespace
  from ast import literal_eval
  from contextlib import suppress
  from functools import wraps
  from typing import Any, Callable, Type, TypeVar, cast
label_desc: Use image node_id 1 for calling a global function with example usage: _parse_env_variables(cls, template) and returns: Namespace