parameters: (func, op_name, clazz_object=ops.Tensor)
docstring: Register operators with different tensor and scalar versions.
  
    If `clazz_object` is `SparseTensor`, assumes `func` takes `(sp_indices,
    sp_values, sp_shape, dense)` and outputs `(new_sp_values)`.
  
    Args:
      func: the operator
      op_name: name of the operator being overridden
      clazz_object: class to override for.  Either `Tensor` or `SparseTensor`.
docstring_summary: Register operators with different tensor and scalar versions.
docstring_tokens: Register operators with different tensor and scalar versions .
function: def _OverrideBinaryOperatorHelper(func, op_name, clazz_object=ops.Tensor):
    """Register operators with different tensor and scalar versions.
  
    If `clazz_object` is `SparseTensor`, assumes `func` takes `(sp_indices,
    sp_values, sp_shape, dense)` and outputs `(new_sp_values)`.
  
    Args:
      func: the operator
      op_name: name of the operator being overridden
      clazz_object: class to override for.  Either `Tensor` or `SparseTensor`.
    """
    def binary_op_wrapper(x, y):
      with ops.op_scope([x, y], None, op_name) as name:
        if not isinstance(y, ops.SparseTensor):
          y = ops.convert_to_tensor(y, dtype=x.dtype.base_dtype, name="y")
        return func(x, y, name=name)
  
    def binary_op_wrapper_sparse(sp_x, y):
      with ops.op_scope([sp_x, y], None, op_name) as name:
        y = ops.convert_to_tensor(y, dtype=sp_x.dtype.base_dtype, name="y")
        return ops.SparseTensor(sp_x.indices, func(sp_x.indices, sp_x.values,
                                                   sp_x.shape, y, name=name),
                                sp_x.shape)
  
    def r_binary_op_wrapper(y, x):
      with ops.op_scope([x, y], None, op_name) as name:
        x = ops.convert_to_tensor(x, dtype=y.dtype.base_dtype, name="x")
        return func(x, y, name=name)
  
    if clazz_object is ops.Tensor:
      clazz_object._override_operator("__%s__" % op_name, binary_op_wrapper)
      del binary_op_wrapper
      clazz_object._override_operator("__r%s__" % op_name, r_binary_op_wrapper)
      del r_binary_op_wrapper
    else:
      clazz_object._override_operator("__%s__" % op_name,
                                      binary_op_wrapper_sparse)
      del binary_op_wrapper_sparse
function_tokens: def _OverrideBinaryOperatorHelper ( func , op_name , clazz_object = ops . Tensor ) : def binary_op_wrapper ( x , y ) : with ops . op_scope ( [ x , y ] , None , op_name ) as name : if not isinstance ( y , ops . SparseTensor ) : y = ops . convert_to_tensor ( y , dtype = x . dtype . base_dtype , name = "y" ) return func ( x , y , name = name ) def binary_op_wrapper_sparse ( sp_x , y ) : with ops . op_scope ( [ sp_x , y ] , None , op_name ) as name : y = ops . convert_to_tensor ( y , dtype = sp_x . dtype . base_dtype , name = "y" ) return ops . SparseTensor ( sp_x . indices , func ( sp_x . indices , sp_x . values , sp_x . shape , y , name = name ) , sp_x . shape ) def r_binary_op_wrapper ( y , x ) : with ops . op_scope ( [ x , y ] , None , op_name ) as name : x = ops . convert_to_tensor ( x , dtype = y . dtype . base_dtype , name = "x" ) return func ( x , y , name = name ) if clazz_object is ops . Tensor : clazz_object . _override_operator ( "__%s__" % op_name , binary_op_wrapper ) del binary_op_wrapper clazz_object . _override_operator ( "__r%s__" % op_name , r_binary_op_wrapper ) del r_binary_op_wrapper else : clazz_object . _override_operator ( "__%s__" % op_name , binary_op_wrapper_sparse ) del binary_op_wrapper_sparse