import torch
from torch.autograd import Variable
from common.constants import Constants
import torch.nn.functional as F
class Cluster_Assignment_Hardening_Loss(torch.nn.Module):
def __init__(self):
    super(Cluster_Assignment_Hardening_Loss,self).__init__()

def forward(self,encode_output, centroids):

    # Calculate q_ij (Eqn-4 of the paper)
    q_temp = Variable(torch.zeros(size = (len(encode_output),len(centroids)), requires_grad=True))

    for i in range(len(encode_output)):
        for j in range(len(centroids)):
            a = encode_output[i] - centroids[j]
            b = torch.pow(a.norm(2),2)
            q_temp[i][j] = torch.pow((1+b/Constants.MU),-(Constants.MU+1)/2)


    col_sum = torch.sum(q_temp,dim=1)  # --
    for i in range(len(encode_output)):
        q_temp[i] = q_temp[i]/col_sum[i]

    # Calculate p_ij (Eqn-5 of paper)
    p_temp = Variable(torch.zeros(size = (len(encode_output),len(centroids)), requires_grad=True))
    temp = torch.pow(p_temp,2)
    row_sum = torch.sum(q_temp,dim=0)     # ||

    for j in range(len(centroids)):
        p_temp[:,j] = q_temp[:,j]/row_sum[j]

    col_sum = torch.sum(p_temp, dim=1)  # --
    for i in range(len(encode_output)):
        p_temp[i] = p_temp[i]/col_sum[i]

    kl_div = F.kl_div(p_temp, q_temp)
    return kl_div

I have created a custom loss function which ultimately calculates KL-diveregence between p_temp and q_temp. Both the encode_input and centroids are tensors.
But I am getting the following error:
kl_div = F.kl_div(p_temp, q_temp)
RuntimeError: the derivative for ‘target’ is not implemented
What could be the issue?