code: def temp_setattr(
      obj, attr: str, value
  ) -> Generator[None, None, None]:
      """Temporarily set attribute on an object.
  
      Args:
          obj: Object whose attribute will be modified.
          attr: Attribute to modify.
          value: Value to temporarily set attribute to.
  
      Yields:
          obj with modified attribute.
      """
      old_value = getattr(obj, attr)
      setattr(obj, attr, value)
      try:
          yield obj
      finally:
          setattr(obj, attr, old_value)
  
imports: from __future__ import annotations
  import builtins
  from collections import abc, defaultdict
  import contextlib
  from functools import partial
  import inspect
  from typing import TYPE_CHECKING, Any, Callable, Collection, Generator, Hashable, Iterable, Sequence, cast, overload
  import warnings
  import numpy
  from pandas._libs import lib
  from pandas._typing import AnyArrayLike, ArrayLike, NpDtype, RandomState, T
  from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike
  from pandas.core.dtypes.common import is_array_like, is_bool_dtype, is_extension_array_dtype, is_integer
  from pandas.core.dtypes.generic import ABCExtensionArray, ABCIndex, ABCSeries
  from pandas.core.dtypes.inference import iterable_not_string
  from pandas.core.dtypes.missing import isna
label_desc: Use image node_id 30 for calling a global function with example usage: temp_setattr(obj, attr, value) without return types