So in simple case as dice loss, option 2 will be fine right?
But there is still one thing that I must understand, they got this function:

  
      github.com
  
  
    perone/medicaltorch/blob/master/medicaltorch/losses.py#L4 3

import torch
from torch.nn import Module


def dice_loss(input, target):
"""Dice loss.


:param input: The input (predicted)
:param target:  The target (ground truth)
:returns: the Dice score between 0 and 1.
"""
eps = 0.0001


iflat = input.view(-1)
tflat = target.view(-1)



  
  
    
    
  
  


And in here:https://github.com/perone/medicaltorch/blob/master/examples/gmchallenge_unet.py#L115 10
They’re doing backward() to this function, am I misunderstanding something, isn’t backward() is just for loss functions? how can he know that this is a loss function there is nothing special about this function.
I know that dice loss have many implementations just waiting for me to grab them, but I have to understand first, sorry.
Thanks, for your help.