code: def _recursive_apply(
      replacement: _typing.Union[list, tuple, dict, set, _torch.Tensor],
      target: _typing.Union[_torch.Tensor, int, float],
  ) -> _typing.Union[_torch.Tensor, int, float]:
      if not isinstance(replacement, type(target)):
          if isinstance(
              replacement, _torch.Tensor
          ) and not _utils._is_container(target):
              return type(target)(replacement.item())
          raise ValueError(
              "Expected an non-container type for target, but got {} with value "
              "{}".format(type(target), target)
          )
      elif isinstance(replacement, _torch.Tensor) and isinstance(
          target, _torch.Tensor
      ):
          replacement = replacement.to(target.device)
          target.data = replacement.data
          return target
      if isinstance(target, list):
          return type(target)(
              [
                  _recursive_apply(r, t)
                  for r, t in zip(replacement, target)
              ]
          )
      elif isinstance(target, tuple):
          return type(target)(
              [
                  _recursive_apply(r, t)
                  for r, t in zip(replacement, target)
              ]
          )
      elif isinstance(replacement, dict) and isinstance(target, dict):
          return type(target)(
              {
                  k: _recursive_apply(r, t)
                  for (_, r), (k, t) in zip(
                      replacement.items(), target.items()
                  )
              }
          )
      elif isinstance(target, set):
          return type(target)(
              {
                  _recursive_apply(r, t)
                  for r, t in zip(replacement, target)
              }
          )
      else:
          raise ValueError(
              "Couldn't apply replacement of type {} to target of type "
              "{}".format(type(replacement), type(target))
          )
  
imports: import abc
  import collections
  import copy
  import math
  import typing
  import warnings
  import torch
  from .None import patch
  from .None import utils
label_desc: Use image node_id 11 for calling a global function with example usage: _recursive_apply(replacement, target) and returns: type, type, target, type, type, type