Thanks for your reply. So I just need remove some data in that list I won’t use then this error will be done. if so, maybe I could save the data in my pc local memery then remove them all? Maybe I should try just use the hook with Tensor. After I change it, I will put the result there. And sorry to ask this stupid question. If you  have free time, could you check this code which I inplement the Focal Loss. Since I use the loss, the value of loss return just like -2000, -1980…
class FocalLoss(nn.Module):

    def __init__(self, alpha=0, gamma=0, eps=1e-7):
        super(FocalLoss, self).__init__()
        self.alpha = alpha
        self.gamma = gamma
        self.eps = eps
        self.ce = nn.CrossEntropyLoss()

    def forward(self, input, target):
        logit = self.ce(input, target)
        p = torch.exp(-logit)

        if self.alpha:
            loss = -1 * self.alpha * (1 - p) ** self.gamma * logit
        else:
            loss = torch.clamp(-((1 - p) ** self.gamma) * logit, self.eps)  # focal loss

        return loss.mean()