Suppose, I have a tensor of N*K, where N represents the number of a batch.
import torch
a = torch.Tensor(1000, 1)
dist = torch.Tensor(1000, 100)
points = torch.arange(100)
# for each a[i], I need to calculate the `distance loss` with each point.
for i in range(a.size(0)):
    for j in range(points.size(0)):
        dist[i][j] = 1/(0.1*torch.pow((a[i] - points[j]), 2) + 1e-8)

However, it is too slow using for-loop. Does anyone have better solutions?