parameters: (self, pred, gt, mask, weights=None)
return_statement: return loss
docstring: DiceLoss function.
docstring_summary: DiceLoss function.
docstring_tokens: DiceLoss function .
function: def forward(self, pred, gt, mask, weights=None):
          """
          DiceLoss function.
          """
  
          assert pred.shape == gt.shape
          assert pred.shape == mask.shape
          if weights is not None:
              assert weights.shape == mask.shape
              mask = weights * mask
          intersection = paddle.sum(pred * gt * mask)
  
          union = paddle.sum(pred * mask) + paddle.sum(gt * mask) + self.eps
          loss = 1 - 2.0 * intersection / union
          assert loss <= 1
          return loss
function_tokens: def forward ( self , pred , gt , mask , weights = None ) : assert pred . shape == gt . shape assert pred . shape == mask . shape if weights is not None : assert weights . shape == mask . shape mask = weights * mask intersection = paddle . sum ( pred * gt * mask ) union = paddle . sum ( pred * mask ) + paddle . sum ( gt * mask ) + self . eps loss = 1 - 2.0 * intersection / union assert loss <= 1 return loss