code: def save_hyperparameters(
      obj: Any,
      *args: Any,
      ignore: Optional[Union[Sequence[str], str]] = None,
      frame: Optional[types.FrameType] = None,
  ) -> None:
      """See :meth:`~lightning.pytorch.LightningModule.save_hyperparameters`"""
  
      if len(args) == 1 and not isinstance(args, str) and not args[0]:
          # args[0] is an empty container
          return
  
      if not frame:
          current_frame = inspect.currentframe()
          # inspect.currentframe() return type is Optional[types.FrameType]: current_frame.f_back called only if available
          if current_frame:
              frame = current_frame.f_back
      if not isinstance(frame, types.FrameType):
          raise AttributeError(
              "There is no `frame` available while being required."
          )
  
      if is_dataclass(obj):
          init_args = {
              f.name: getattr(obj, f.name) for f in fields(obj)
          }
      else:
          init_args = {}
  
          from lightning.pytorch.core.mixins import HyperparametersMixin
  
          for local_args in collect_init_args(
              frame, [], classes=(HyperparametersMixin,)
          ):
              init_args.update(local_args)
  
      if ignore is None:
          ignore = []
      elif isinstance(ignore, str):
          ignore = [ignore]
      elif isinstance(ignore, (list, tuple)):
          ignore = [arg for arg in ignore if isinstance(arg, str)]
  
      ignore = list(set(ignore))
      init_args = {
          k: v for k, v in init_args.items() if k not in ignore
      }
  
      if not args:
          # take all arguments
          hp = init_args
          obj._hparams_name = "kwargs" if hp else None
      else:
          # take only listed arguments in `save_hparams`
          isx_non_str = [
              i
              for i, arg in enumerate(args)
              if not isinstance(arg, str)
          ]
          if len(isx_non_str) == 1:
              hp = args[isx_non_str[0]]
              cand_names = [k for k, v in init_args.items() if v == hp]
              obj._hparams_name = cand_names[0] if cand_names else None
          else:
              hp = {
                  arg: init_args[arg]
                  for arg in args
                  if isinstance(arg, str)
              }
              obj._hparams_name = "kwargs"
  
      # `hparams` are expected here
      obj._set_hparams(hp)
  
      for k, v in obj._hparams.items():
          if isinstance(v, nn.Module):
              rank_zero_warn(
                  f"Attribute {k!r} is an instance of `nn.Module` and is already saved during checkpointing."
                  f" It is recommended to ignore them using `self.save_hyperparameters(ignore=[{k!r}])`."
              )
  
      # make a deep copy so there are no other runtime changes reflected
      obj._hparams_initial = copy.deepcopy(obj._hparams)
  
imports: import copy
  import inspect
  import pickle
  import types
  from dataclasses import fields, is_dataclass
  from typing import Any, Dict, List, Literal, MutableMapping, Optional, Sequence, Tuple, Type, Union
  from torch import nn
  import lightning.pytorch
  from lightning.fabric.utilities.data import AttributeDict
  from lightning.pytorch.utilities.rank_zero import rank_zero_warn
label_desc: Use image node_id 7 for calling a global function with example usage: save_hyperparameters(obj) without return types