def binary_op_wrapper(x, y):
    with ops.name_scope(None, op_name, [x, y]) as name:
        if (isinstance(x, ops.Tensor) and isinstance(y, ops.Tensor)):
            return func(x, y, name=name)
        elif (not isinstance(y, sparse_tensor.SparseTensor)):
            try:
                y = ops.convert_to_tensor_v2(y, dtype_hint=x.dtype.base_dtype, name='y')
            except TypeError:
                if hasattr(type(y), ('__r%s__' % op_name)):
                    return NotImplemented
                else:
                    raise
        return func(x, y, name=name)
def binary_op_wrapper(x, y):
    with ops.name_scope(None, op_name, [x, y]) as name:
        if (isinstance(x, ops.Tensor) and isinstance(y, ops.Tensor)):
            return func(x, y, name=name)
        elif (not isinstance(y, sparse_tensor.SparseTensor)):
            try:
                y = ops.convert_to_tensor_v2(y, dtype_hint=x.dtype.base_dtype, name='y')
            except TypeError:
                if hasattr(type(y), ('__r%s__' % op_name)):
                    return NotImplemented
                else:
                    raise
        return func(x, y, name=name)