import torch


def batch_mvp(m, v):
    """Batched matrix vector product.

    Args:
        m: A tensor of size (batch_size, d, m).
        v: A tensor of size (batch_size, m).

    Returns:
        A tensor of size (batch_size, d).
    """
    v = v.unsqueeze(dim=-1)  # (batch_size, m, 1)
    mvp = torch.bmm(m, v)  # (batch_size, d, 1)
    mvp = mvp.squeeze(dim=-1)  # (batch_size, d)
    return mvp