import torch


def intersect_centered(wh_a: torch.Tensor, wh_b: torch.Tensor) -> torch.Tensor:
    """Calculates intersection of same centered boxes

    Args:
        wh_a (torch.Tensor): torch.Tensor(A,2) as width,height
        wh_b (torch.Tensor): torch.Tensor(B,2) as width,height

    Returns:
        torch.Tensor: torch.Tensor(A,B)
    """

    A = wh_a.size(0)
    B = wh_b.size(0)
    min_w = torch.min(
        wh_a[:, [0]].unsqueeze(1).expand(A, B, 2),
        wh_b[:, [0]].unsqueeze(0).expand(A, B, 2),
    )

    # [A,2] -> [A,1,2] -> [A,B,2]

    min_h = torch.min(
        wh_a[:, [1]].unsqueeze(1).expand(A, B, 2),
        wh_b[:, [1]].unsqueeze(0).expand(A, B, 2),
    )
    # [B,2] -> [1,B,2] -> [A,B,2]

    return min_w[:, :, 0] * min_h[:, :, 0]