Thanks,
Finally I use pairwise_distance instead of minus operator, and now the code is work fine.
Here is the working code:
class CrossOverLoss(nn.Module):
    def __init__(self):
        super(CrossOverLoss, self).__init__()

    def forward(self, x, y):
        batch_size, n = y.size()
        x = x.squeeze()
        d = pairwise_distance(x, y)      
        return torch.sum(d) / batch_size