parameters: (labeled_tensor_0, labeled_tensor_1, name=None)
docstring: Align the axes of two tensors so they may be broadcast to each other.
  
    Axes are ordered by the current axis order scope, if present, or by the left-
    most consistent ordering. An exception is raised if it is impossible to align
    the tensors without a transpose (align never copies the input data).
  
    Example usage:
  
      >>> a = lt.LabeledTensor(tf.ones((2, 4)), ['x', 'z'])
      >>> b = lt.LabeledTensor(tf.ones((3, 4)), ['y', 'z'])
      >>> a2, b2, axes = lt.align(a, b)
      >>> a2
      <LabeledTensor 'lt_align_1/lt_align_1/0:...' shape=(2, 1, 4) dtype=float32
       axes=[('x', Dimension(2)),
             ('y', Dimension(1)),
             ('z', Dimension(4))]>
      >>> b2
      <LabeledTensor 'lt_align_1/lt_align_1/1:...' shape=(1, 3, 4) dtype=float32
       axes=[('x', Dimension(1)),
             ('y', Dimension(3)),
             ('z', Dimension(4))]>
      >>> axes
      Axes([('x', Dimension(2)),
            ('y', Dimension(3)),
            ('z', Dimension(4))])
  
    Args:
      labeled_tensor_0: An input tensor.
      labeled_tensor_1: An input tensor.
      name: Optional op name.
  
    Returns:
      The aligned tensors and the axes the resulting tensor would have if the two
      aligned tensors were broadcast to each other. The aligned tensors have the
      same rank but not necessarily the same shape, with axes in the same order.
  
    Raises:
      ValueError: If axes with the same name on the inputs are not equal.
      AxisOrderError: If there is no way to reshape the input tensors into the
        output without a transpose.
docstring_summary: Align the axes of two tensors so they may be broadcast to each other.
docstring_tokens: Align the axes of two tensors so they may be broadcast to each other .
function: def align(labeled_tensor_0, labeled_tensor_1, name=None):
    """Align the axes of two tensors so they may be broadcast to each other.
  
    Axes are ordered by the current axis order scope, if present, or by the left-
    most consistent ordering. An exception is raised if it is impossible to align
    the tensors without a transpose (align never copies the input data).
  
    Example usage:
  
      >>> a = lt.LabeledTensor(tf.ones((2, 4)), ['x', 'z'])
      >>> b = lt.LabeledTensor(tf.ones((3, 4)), ['y', 'z'])
      >>> a2, b2, axes = lt.align(a, b)
      >>> a2
      <LabeledTensor 'lt_align_1/lt_align_1/0:...' shape=(2, 1, 4) dtype=float32
       axes=[('x', Dimension(2)),
             ('y', Dimension(1)),
             ('z', Dimension(4))]>
      >>> b2
      <LabeledTensor 'lt_align_1/lt_align_1/1:...' shape=(1, 3, 4) dtype=float32
       axes=[('x', Dimension(1)),
             ('y', Dimension(3)),
             ('z', Dimension(4))]>
      >>> axes
      Axes([('x', Dimension(2)),
            ('y', Dimension(3)),
            ('z', Dimension(4))])
  
    Args:
      labeled_tensor_0: An input tensor.
      labeled_tensor_1: An input tensor.
      name: Optional op name.
  
    Returns:
      The aligned tensors and the axes the resulting tensor would have if the two
      aligned tensors were broadcast to each other. The aligned tensors have the
      same rank but not necessarily the same shape, with axes in the same order.
  
    Raises:
      ValueError: If axes with the same name on the inputs are not equal.
      AxisOrderError: If there is no way to reshape the input tensors into the
        output without a transpose.
    """
    with ops.name_scope(name, 'lt_align',
                        [labeled_tensor_0, labeled_tensor_1]) as scope:
  
      labeled_tensor_0 = convert_to_labeled_tensor(labeled_tensor_0)
      labeled_tensor_1 = convert_to_labeled_tensor(labeled_tensor_1)
  
      axes_0 = labeled_tensor_0.axes
      axes_1 = labeled_tensor_1.axes
      for axis_name in axes_0:
        if axis_name in axes_1:
          if axes_0[axis_name] != axes_1[axis_name]:
            raise ValueError('Mismatched %r axis on input tensors: %r and %r' %
                             (axis_name, axes_0[axis_name], axes_1[axis_name]))
  
      axis_scope_order = get_axis_order()
      if axis_scope_order is not None:
        # we are in an axis_order_scope
        axis_names_set = set(axes_0) | set(axes_1)
        new_axis_names = [a for a in axis_scope_order if a in axis_names_set]
  
        check_axis_order(labeled_tensor_0, axis_scope_order)
        check_axis_order(labeled_tensor_1, axis_scope_order)
  
      else:
        # attempt to find a consistent ordering
        new_axis_names = _find_consistent_ordering(list(axes_0), list(axes_1))
        if new_axis_names is None:
          raise AxisOrderError(
              'No consistent axis order allows for aligning tensors with axis '
              'orders %r and %r without copying data. Use transpose or '
              'impose_axis_order to reorder axes on one of more of the inputs.' %
              (axes_0.keys(), axes_1.keys()))
  
      labeled_tensor_0 = expand_dims(
          labeled_tensor_0, new_axis_names, name=scope + '0')
      labeled_tensor_1 = expand_dims(
          labeled_tensor_1, new_axis_names, name=scope + '1')
  
      broadcast_axes = []
      for axis_name in new_axis_names:
        if axis_name in axes_0:
          broadcast_axes.append(axes_0[axis_name])
        else:
          broadcast_axes.append(axes_1[axis_name])
  
      return labeled_tensor_0, labeled_tensor_1, Axes(broadcast_axes)
function_tokens: def align ( labeled_tensor_0 , labeled_tensor_1 , name = None ) : with ops . name_scope ( name , 'lt_align' , [ labeled_tensor_0 , labeled_tensor_1 ] ) as scope : labeled_tensor_0 = convert_to_labeled_tensor ( labeled_tensor_0 ) labeled_tensor_1 = convert_to_labeled_tensor ( labeled_tensor_1 ) axes_0 = labeled_tensor_0 . axes axes_1 = labeled_tensor_1 . axes for axis_name in axes_0 : if axis_name in axes_1 : if axes_0 [ axis_name ] != axes_1 [ axis_name ] : raise ValueError ( 'Mismatched %r axis on input tensors: %r and %r' % ( axis_name , axes_0 [ axis_name ] , axes_1 [ axis_name ] ) ) axis_scope_order = get_axis_order ( ) if axis_scope_order is not None : # we are in an axis_order_scope axis_names_set = set ( axes_0 ) | set ( axes_1 ) new_axis_names = [ a for a in axis_scope_order if a in axis_names_set ] check_axis_order ( labeled_tensor_0 , axis_scope_order ) check_axis_order ( labeled_tensor_1 , axis_scope_order ) else : # attempt to find a consistent ordering new_axis_names = _find_consistent_ordering ( list ( axes_0 ) , list ( axes_1 ) ) if new_axis_names is None : raise AxisOrderError ( 'No consistent axis order allows for aligning tensors with axis ' 'orders %r and %r without copying data. Use transpose or ' 'impose_axis_order to reorder axes on one of more of the inputs.' % ( axes_0 . keys ( ) , axes_1 . keys ( ) ) ) labeled_tensor_0 = expand_dims ( labeled_tensor_0 , new_axis_names , name = scope + '0' ) labeled_tensor_1 = expand_dims ( labeled_tensor_1 , new_axis_names , name = scope + '1' ) broadcast_axes = [ ] for axis_name in new_axis_names : if axis_name in axes_0 : broadcast_axes . append ( axes_0 [ axis_name ] ) else : broadcast_axes . append ( axes_1 [ axis_name ] ) return labeled_tensor_0 , labeled_tensor_1 , Axes ( broadcast_axes )