Yes, I was moving loss to cpu, but now I am remaining it to gpu.
Here are the indicator_functions:

# signed distance function
# H_h(x) = n_h . x + d_h
def sdf(hyperlines, x):
    dist_vector = torch.zeros([hyperlines.size()[0]], dtype=torch.double)
    i = 0
    for x_n, y_n, d_n in hyperlines:
        n_h = torch.tensor([x_n, y_n], dtype=torch.double)
        dist_vector[i] = torch.matmul(n_h, x) + d_n  # n_h[0]*x[0] + n_h[1]*x[1] + d_n
        i += 1
    return dist_vector

def logSumExp(dist_vector, delta):
    return torch.logsumexp(dist_vector, 0)*delta


def sigmoid(sigma, fai_x):
    return torch.sigmoid(sigma * fai_x)

# the Function uses softmax, sigmoid and returns probability of the point x inside object
def estimatedPosition(lines, x):
    dist_vector = sdf(lines, x)
    delta = torch.tensor(1) # 0.006
    fai_x = logSumExp(dist_vector, delta)  # softmax
    sigma = -1 #-75
    estimation = sigmoid(sigma, fai_x)
    return estimation

# function returns 1 if point (x) is inside GT object, returns 0 other wise
def calculated_Position(train_GT_image,x):
    if train_GT_image[x[0].item(), x[1].item()] == 0: return torch.tensor(1.0, dtype=torch.double)
    return torch.tensor(0.0, dtype=torch.double)

One more thing, after loss.backward() when I try print(model.weight.grad) it produces the error as shown below.
(Pdb) print(model.weight.grad)
*** AttributeError: 'SimpleNet' object has no attribute 'weight'