import torch


def cho_solve_AXB(a, L, b):
    """Compute tensor $a C^{-1} b$ from cholesky factor.

    Args:
        a (torch.Tensor): M x N tensor.
        L (torch.Tensor): N x N lower triangular tensor where $L L^T = C$.
        b (torch.Tensor): N x L tensor.

    Returns:
        torch.Tensor: $a C^{-1} b$
    """

    left, _ = torch.triangular_solve(a.t(), L, upper=False)
    right, _ = torch.triangular_solve(b, L, upper=False)
    return torch.mm(left.t(), right)