def batch_eye_like(tensor):
    """
    Creates a sequence of identity tensors indicted by the batch size with the
    shape of the input tensor

    Parameters
    ----------
    tensor: Tensor (b, n, ..., n)
            b tensors with the same shape

    Returns
    -------
    Tensor (b, n, ..., n)
        b identity tensors
    """

    return tensor.new_ones(tensor.size(-1)).diag().expand_as(tensor)