parameters: (self, weight=None, gamma=2.0, reduction='mean')
docstring: Initialize FocalLoss.
docstring_summary: Initialize FocalLoss.
docstring_tokens: Initialize FocalLoss .
function: def __init__(self, weight=None, gamma=2.0, reduction='mean'):
          """Initialize FocalLoss."""
          super(FocalLoss, self).__init__(reduction=reduction)
  
          self.gamma = validator.check_value_type("gamma", gamma, [float])
          if weight is not None and not isinstance(weight, Tensor):
              raise TypeError(f"For '{self.cls_name}', the type of 'weight' should be a Tensor, "
                              f"but got {type(weight).__name__}.")
          if isinstance(weight, Tensor) and weight.ndim != 1:
              raise ValueError(f"For '{self.cls_name}', the dimension of 'weight' should be 1, but got {weight.ndim}.")
          self.weight = weight
          self.expand_dims = P.ExpandDims()
          self.gather_d = P.GatherD()
          self.squeeze = P.Squeeze(axis=1)
          self.tile = P.Tile()
          self.cast = P.Cast()
          self.dtype = P.DType()
          self.logsoftmax = nn.LogSoftmax(1)
function_tokens: def __init__ ( self , weight = None , gamma = 2.0 , reduction = 'mean' ) : super ( FocalLoss , self ) . __init__ ( reduction = reduction ) self . gamma = validator . check_value_type ( "gamma" , gamma , [ float ] ) if weight is not None and not isinstance ( weight , Tensor ) : raise TypeError ( f"For '{self.cls_name}', the type of 'weight' should be a Tensor, " f"but got {type(weight).__name__}." ) if isinstance ( weight , Tensor ) and weight . ndim != 1 : raise ValueError ( f"For '{self.cls_name}', the dimension of 'weight' should be 1, but got {weight.ndim}." ) self . weight = weight self . expand_dims = P . ExpandDims ( ) self . gather_d = P . GatherD ( ) self . squeeze = P . Squeeze ( axis = 1 ) self . tile = P . Tile ( ) self . cast = P . Cast ( ) self . dtype = P . DType ( ) self . logsoftmax = nn . LogSoftmax ( 1 )