def binary_arguments_to_tensors(x1, x2):
  """Convert argument of a binary operation to Tensors.

  Args:
    x1: a Tensor or something convertible to a tf Scalar
    x2: a Tensor or something convertible to a tf Scalar

  Returns:
    new_x1: a Tensor
    new_x2: a Tensor

  Raises:
    ValueError: on failure
  """
  if not isinstance(x1, Tensor) and not isinstance(x2, Tensor):
    raise ValueError("at least one of x1 and x2 must be an mtf Tensor")
  elif isinstance(x1, Tensor) and isinstance(x2, Tensor):
    return x1, x2
  elif isinstance(x1, Tensor):
    return x1, import_tf_tensor(
        x1.mesh, tf.convert_to_tensor(x2, dtype=x1.dtype), Shape([]))
  else:
    return import_tf_tensor(x2.mesh, tf.convert_to_tensor(x1, dtype=x2.dtype),
                            Shape([])), x2
def binary_arguments_to_tensors ( x1 , x2 ) : if not isinstance ( x1 , Tensor ) and not isinstance ( x2 , Tensor ) : raise ValueError ( "at least one of x1 and x2 must be an mtf Tensor" ) elif isinstance ( x1 , Tensor ) and isinstance ( x2 , Tensor ) : return x1 , x2 elif isinstance ( x1 , Tensor ) : return x1 , import_tf_tensor ( x1 . mesh , tf . convert_to_tensor ( x2 , dtype = x1 . dtype ) , Shape ( [ ] ) ) else : return import_tf_tensor ( x2 . mesh , tf . convert_to_tensor ( x1 , dtype = x2 . dtype ) , Shape ( [ ] ) ) , x2
Convert argument of a binary operation to Tensors.

  Args:
    x1: a Tensor or something convertible to a tf Scalar
    x2: a Tensor or something convertible to a tf Scalar

  Returns:
    new_x1: a Tensor
    new_x2: a Tensor

  Raises:
    ValueError: on failure