code: def weak_tensor_binary_op_wrapper(
      op, y_arg_name=None, special_handling=None
  ):
      """Determines result promotion type and adds WeakTensor support to binary ops.
  
      This wrapper first infers dtype of any Tensor, WeakTensor, python/numpy
      inputs. Then, both inputs are promoted to the correct promotion result dtype.
      If the result promotion dtype is "weak", returns WeakTensor.
      """
      signature = inspect.signature(op)
      arg_names = iter(signature.parameters.keys())
      x_arg_name = next(arg_names)
      if y_arg_name is None:
          y_arg_name = next(arg_names)
  
      def wrapper(*args, **kwargs):
          if not ops.is_auto_dtype_conversion_enabled():
              return op(*args, **kwargs)
          bound_arguments = signature.bind(*args, **kwargs)
          bound_arguments.apply_defaults()
          bound_kwargs = bound_arguments.arguments
          x = bound_kwargs[x_arg_name]
          y = bound_kwargs[y_arg_name]
          # Infer input type and determine the result promotion type.
          try:
              target_type, is_weak = flexible_dtypes.result_type(x, y)
          # NotImplementedError is thrown from result_type when x or y is an
          # unsupported input type (e.g. CompositeTensor).
          except NotImplementedError:
              logging.warning(
                  "The new dtype semantics do not support"
                  f" {op.__module__}.{op.__name__}({type(x)}, {type(y)}). Falling back"
                  " to old semantics."
              )
              return op(**bound_kwargs)
  
          if special_handling == "variable_method":
              # Variable dtypes cannot be mutated. Hence we only allow the conversion
              # of `y` and disallow the conversion of `x`.
              if target_type != x.dtype:
                  raise TypeError(
                      f"Variable dtype is immutable. Calling {op.__name__} "
                      f"of Variable (with dtype {x.dtype}) on {y} requires "
                      f"converting {y} to {x.dtype}. This is disabled in the "
                      f"current promotion semantics. Please convert {y} "
                      f"manually before calling {op.__name__}."
                  )
  
              bound_kwargs[y_arg_name] = _convert_or_cast(
                  y, target_type, "y"
              )
              return op(**bound_kwargs)
          # TODO(b/293935420): Remove this branch and make a separate patch function
          # for tf.constant.
          elif special_handling == "constant":
              # Convert WeakTensor input to tensor because the dtype check in
              # convert_to_eager_tensor only occurs if x is an EagerTensor.
              if isinstance(x, weak_tensor.WeakTensor):
                  bound_kwargs[x_arg_name] = x.to_tensor()
              # tf.constant(x, dtype) should always return a Tensor of specified dtype.
              # Hence we only allow the one-way conversion from `x` to the dtype arg.
              if y is not None:
                  is_weak = False
                  if target_type != y:
                      # If promtion is not successful, rely on tf.constant to handle the
                      # conversion.
                      return op(**bound_kwargs)
                  # Only need to explicity call convert_or_cast for Tensor/WeakTensor
                  # inputs. Other types are automatically converted to the specified
                  # dtype in tf.constant.
                  if isinstance(x, core.Tensor):
                      bound_kwargs[x_arg_name] = _convert_or_cast(
                          x, target_type, "x"
                      )
              else:
                  bound_kwargs["dtype"] = target_type
          else:
              bound_kwargs[x_arg_name] = _convert_or_cast(
                  x, target_type, "x"
              )
              bound_kwargs[y_arg_name] = _convert_or_cast(
                  y, target_type, "y"
              )
          if special_handling == "comparison-method":
              # No need for "weak" return value for comparison method.
              is_weak = False
          return weak_tensor.convert_to_weak_tensor_or_tensor(
              op(**bound_kwargs), is_weak
          )
  
      wrapper = tf_decorator.make_decorator(op, wrapper)
  
      # Update dispatch dictionary to store monkey-patched op references.
      _update_weak_tensor_patched_ops_in_dispatch_dict(wrapper)
  
      # Add the updated function to list of binary ops with WeakTensor support.
      _TF_BINARY_APIS.append(wrapper)
      return wrapper
  
imports: import inspect
  from tensorflow.python.framework import composite_tensor
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import flexible_dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor
  from tensorflow.python.framework import weak_tensor
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import clip_ops
  from tensorflow.python.ops import gen_array_ops
  from tensorflow.python.ops import gen_bitwise_ops
  from tensorflow.python.ops import gen_math_ops
  from tensorflow.python.ops import image_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import nn_impl
  from tensorflow.python.ops import nn_ops
  from tensorflow.python.ops import resource_variable_ops
  from tensorflow.python.ops import special_math_ops
  from tensorflow.python.ops.numpy_ops import np_array_ops
  from tensorflow.python.ops.numpy_ops import np_math_ops
  from tensorflow.python.platform import tf_logging
  from tensorflow.python.types import core
  from tensorflow.python.util import dispatch
  from tensorflow.python.util import tf_decorator
label_desc: Use image node_id 3 for calling a global function with example usage: weak_tensor_binary_op_wrapper(op, y_arg_name, special_handling) and returns: wrapper, weak_tensor, op, op, op, op