import torch


def inner_product(this, that, keepdim=True):
    """
    Calculate the inner product of two tensors along the last dimension

    Inputs:
        this, that          ...xD torch.tensors containing the vectors
    
    Outputs:
        result              ... torch.tensor containing the inner products
    """
    return torch.sum(this*that, dim=-1, keepdim=keepdim)