I apologize for the delay.
about self.labelInterest Yes you guessed right.I removed last re-wrapping but nothing changed.
I changed my code to :
import torch.nn.functional as F
import torch.nn as nn
class SoftDiceLoss(nn.Module):
    def __init__(self, label_of_interest=1, weight=None, size_average=True):
        super(SoftDiceLoss, self).__init__()
        self.labelInterest = label_of_interest

    def forward(self, logits, targets):
        smooth = 1
        num = targets.size(0)
         
        m1 =  logits.view(num, -1)
        m2 = targets.view(num, -1)
        intersection = ((m1==self.labelInterest) * (m2==self.labelInterest) )

        score = 2. * (intersection.sum() + smooth).float() / ((m1==self.labelInterest).sum() + (m2==self.labelInterest).sum() + smooth).float()
        score = 1 - score 
        score.requires_grad=True #I get an error without this line of code. It is necessary
         
        return score


but nothing changed ! I even changed the learning rate many times, but it did not have any effect .
what do think about override backward function?is it good idea for this problem?