code: def copy_with(obj: T, **kwargs) -> T:
      """Return copy of `obj` and update attributes of the copy using `kwargs`.
  
      ::
  
          @dataclass
          class MyClass:
              value: int
  
          a = MyClass(1)
          b = copy_with(a, value=2)
  
          assert a.value == 1
          assert b.value == 2
  
      """
  
      new_obj = copy.copy(obj)
  
      for name, value in kwargs.items():
          setattr(new_obj, name, value)
  
      return new_obj
  
imports: import copy
  import tarfile
  from functools import lru_cache
  from pathlib import Path
  from typing import TYPE_CHECKING, TypeVar
label_desc: Use image node_id 1 for calling a global function with example usage: copy_with(obj) and returns: new_obj