def dist_l2(x1, x2):
    """
        compute l2 distance between two tensors
        x1: Tensor of shape (h1, w)
        x2: Tensor of shape (h2, w)
        Return pairwise l2 distance for each row vector in x1, x2 as
        a Tensor of shape (h1, h2)
    """
    x1=x1.unsqueeze(0)
    x2=x2.unsqueeze(1)
    diff_square=(x1-x2)**2 # h1,h2,w
    diff_sum=diff_square.sum(dim=-1)
    l2_dist=diff_sum**0.5
    return l2_dist