code: def _defaults_from_env_vars(fn: _T) -> _T:
      @wraps(fn)
      def insert_env_defaults(
          self: Any, *args: Any, **kwargs: Any
      ) -> Any:
          cls = self.__class__  # get the class
          if args:  # in case any args passed move them to kwargs
              # parse the argument names
              cls_arg_names = inspect.signature(cls).parameters
              # convert args to kwargs
              kwargs.update(dict(zip(cls_arg_names, args)))
          env_variables = vars(_parse_env_variables(cls))
          # update the kwargs by env variables
          kwargs = dict(
              list(env_variables.items()) + list(kwargs.items())
          )
  
          # all args were already moved to kwargs
          return fn(self, **kwargs)
  
      return cast(_T, insert_env_defaults)
  
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 2 for calling a global function with example usage: _defaults_from_env_vars(fn) and returns: cast, fn