Hİ nikronic, thanks for comment. Actually i referred to this;
dice_loss = Dice_Loss()

and used this
print(output.size(),type(output))
print(labels.size(),type(labels))
loss_dice= dice_loss(labels,output)
loss_dice.backward()

When I debug it by eyes again i couldn’t find any problem or i am quite  careless