code: def _trimmed_work(
      work: LightningWork, to_trim: typing.List[str]
  ) -> typing.Iterator[None]:
      """Context manager to trim the work object to remove attributes that are not picklable."""
      holder = {}
      for arg in to_trim:
          holder[arg] = getattr(work, arg)
          setattr(work, arg, None)
      yield
      for arg in to_trim:
          setattr(work, arg, holder[arg])
  
file_path: pytorch-lightning/src/lightning/app/utilities/safe_pickle.py
imports: import contextlib
  import pickle
  import sys
  import types
  import typing
  from copy import deepcopy
  from pathlib import Path
  from lightning.app.core.work import LightningWork
  from lightning.app.utilities.app_helpers import _LightningAppRef
label_desc: Use image node_id 1 for calling a global function with example usage: _trimmed_work(work, to_trim) without return types