Hi, Thanks for reply…
Yes, am aware of that.  am not using BCE loss, am using my own defined focalloss,which I used NLLLOSS inside.
class FocalLossnd(nn.Module):
    def __init__(self, weights=None, gamma=0, reduction='mean', ignore_idx=255):
        super().__init__()
        self.weights = weights
        self.gamma = gamma
        self.reduction= reduction
        self.eps = 1e-6
        self.ignore_idx = ignore_idx

    def forward(self, pred, target):
        target = target.type(torch.cuda.LongTensor)
        pt = torch.softmax(pred, dim=1)
        focal_weights = torch.pow((torch.ones(1).to(pred.device) - pt), self.gamma)
        focal = focal_weights * torch.log(pt + self.eps)

        criterion = nn.NLLLoss(
            weight=self.weights,
            ignore_index=self.ignore_idx,
            reduction=self.reduction)
        loss = criterion(focal, target)

        return loss