import torch


def inner_product_similarity(a: torch.Tensor, b: torch.Tensor, dim: int = 1) -> torch.Tensor:
    """
    Calculate inner product of two vectors
    
    Args:
        a (T, shape = (B, N_{a}, E)), data_type=torch.float: the first batch of vector to be multiplied
        b (T, shape = (B, N_{b}, E)), data_type=torch.float: the second batch of vector to be multiplied
        dim (int): dimension to sum the tensor
    
    Returns:
        T, data_type=torch.float: inner product tensor
    """
    return (a * b).sum(dim=dim)