def METHOD_NAME(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])