def _check_maybe(tensor):
    """ Checks that the tensor has a known rank. """
    if tensor.shape.ndims is None:
        raise ValueError(
            'Expected tensor (%s) to have known rank, but ndims == None.' %
            tensor)
