code: def temp_setattr(
      obj, attr: str, value, condition: bool = True
  ) -> Generator[None, None, None]:
      """
      Temporarily set attribute on an object.
  
      Parameters
      ----------
      obj : object
          Object whose attribute will be modified.
      attr : str
          Attribute to modify.
      value : Any
          Value to temporarily set attribute to.
      condition : bool, default True
          Whether to set the attribute. Provided in order to not have to
          conditionally use this context manager.
  
      Yields
      ------
      object : obj with modified attribute.
      """
      if condition:
          old_value = getattr(obj, attr)
          setattr(obj, attr, value)
      try:
          yield obj
      finally:
          if condition:
              setattr(obj, attr, old_value)
  
imports: from __future__ import annotations
  import builtins
  from collections import abc, defaultdict
  from collections.abc import Collection, Generator, Hashable, Iterable, Sequence
  import contextlib
  from functools import partial
  import inspect
  from typing import TYPE_CHECKING, Any, Callable, TypeVar, cast, overload
  import warnings
  import numpy
  from pandas._libs import lib
  from pandas.compat.numpy import np_version_gte1p24
  from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike
  from pandas.core.dtypes.common import is_bool_dtype, is_integer
  from pandas.core.dtypes.generic import ABCExtensionArray, ABCIndex, ABCMultiIndex, ABCSeries
  from pandas.core.dtypes.inference import iterable_not_string
label_desc: Use image node_id 32 for calling a global function with example usage: temp_setattr(obj, attr, value, condition) without return types