def _tensordot_axes(a, axes):
    'Generates two sets of contraction axes for the two tensor arguments.'
    a_shape = a.get_shape()
    if isinstance(axes, compat.integral_types):
        if (axes < 0):
            raise ValueError("'axes' must be at least 0.")
        if (a_shape.ndims is not None):
            if (axes > a_shape.ndims):
                raise ValueError(("'axes' must not be larger than the number of dimensions of tensor %s." % a))
            return (list(xrange((a_shape.ndims - axes), a_shape.ndims)), list(xrange(axes)))
        else:
            rank = array_ops.rank(a)
            return (range((rank - axes), rank, dtype=dtypes.int32), range(axes, dtype=dtypes.int32))
    elif isinstance(axes, (list, tuple)):
        if (len(axes) != 2):
            raise ValueError("'axes' must be an integer or have length 2.")
        a_axes = axes[0]
        b_axes = axes[1]
        if (isinstance(a_axes, compat.integral_types) and isinstance(b_axes, compat.integral_types)):
            a_axes = [a_axes]
            b_axes = [b_axes]
        if (len(a_axes) != len(b_axes)):
            raise ValueError(("Different number of contraction axes 'a' and 'b', %s != %s." % (len(a_axes), len(b_axes))))
        return (a_axes, b_axes)
    else:
        axes = ops.convert_to_tensor(axes, name='axes', dtype=dtypes.int32)
        return (axes[0], axes[1])
Generates two sets of contraction axes for the two tensor arguments.
def _tensordot_axes(a, axes):
    
    a_shape = a.get_shape()
    if isinstance(axes, compat.integral_types):
        if (axes < 0):
            raise ValueError("'axes' must be at least 0.")
        if (a_shape.ndims is not None):
            if (axes > a_shape.ndims):
                raise ValueError(("'axes' must not be larger than the number of dimensions of tensor %s." % a))
            return (list(xrange((a_shape.ndims - axes), a_shape.ndims)), list(xrange(axes)))
        else:
            rank = array_ops.rank(a)
            return (range((rank - axes), rank, dtype=dtypes.int32), range(axes, dtype=dtypes.int32))
    elif isinstance(axes, (list, tuple)):
        if (len(axes) != 2):
            raise ValueError("'axes' must be an integer or have length 2.")
        a_axes = axes[0]
        b_axes = axes[1]
        if (isinstance(a_axes, compat.integral_types) and isinstance(b_axes, compat.integral_types)):
            a_axes = [a_axes]
            b_axes = [b_axes]
        if (len(a_axes) != len(b_axes)):
            raise ValueError(("Different number of contraction axes 'a' and 'b', %s != %s." % (len(a_axes), len(b_axes))))
        return (a_axes, b_axes)
    else:
        axes = ops.convert_to_tensor(axes, name='axes', dtype=dtypes.int32)
        return (axes[0], axes[1])