code: def _reconstruct(
      x,
      memo,
      func,
      args,
      state=None,
      listiter=None,
      dictiter=None,
      *,
      deepcopy=deepcopy,
  ):
      deep = memo is not None
      if deep and args:
          args = (deepcopy(arg, memo) for arg in args)
      y = func(*args)
      if deep:
          memo[id(x)] = y
  
      if state is not None:
          if deep:
              state = deepcopy(state, memo)
          if hasattr(y, "__setstate__"):
              y.__setstate__(state)
          else:
              if isinstance(state, tuple) and len(state) == 2:
                  state, slotstate = state
              else:
                  slotstate = None
              if state is not None:
                  y.__dict__.update(state)
              if slotstate is not None:
                  for key, value in slotstate.items():
                      setattr(y, key, value)
  
      if listiter is not None:
          if deep:
              for item in listiter:
                  item = deepcopy(item, memo)
                  y.append(item)
          else:
              for item in listiter:
                  y.append(item)
      if dictiter is not None:
          if deep:
              for key, value in dictiter:
                  key = deepcopy(key, memo)
                  value = deepcopy(value, memo)
                  y[key] = value
          else:
              for key, value in dictiter:
                  y[key] = value
      return y
  
file_path: catboost/contrib/tools/python3/src/Lib/copy.py
imports: import types
  import weakref
  from copyreg import dispatch_table
label_desc: Use image node_id 10 for calling a global function with example usage: _reconstruct(x, memo, func, args, state, listiter, dictiter) and returns: y