o  i @sfddlmZddlZddlZddlmZddlmZmZddl Z ddl m Z dgZ Gddde Z dS)) annotationsN)Callable)AnyOptional)_Loss MaskedLosscs.eZdZdZdfd d ZddddZZS)rz This is a wrapper class for the loss functions. It allows for additional weighting masks to be applied to both input and target. See Also: - :py:class:`monai.losses.MaskedDiceLoss` losstt|r||i|n||_t|jstddS)a? Args: loss: loss function to be wrapped, this could be a loss class or an instance of a loss class. loss_args: arguments to the loss function's constructor if `loss` is a class. loss_kwargs: keyword arguments to the loss function's constructor if `loss` is a class. z"The loss function is not callable.N)super__init__inspectisclassrcallable ValueError)selfrr r  __class__[/home/dell461/cl/sdc2/last_ska_mid/HISourceFinder-master-l/src/monai/losses/spatial_mask.pyr"s  zMaskedLoss.__init__Ninput torch.TensortargetmaskOptional[torch.Tensor]cCs|durtd|||S||kr%td|jd|jd|jd|jdkrC|jddkrCtd|jd |jd|dkru|jddkrYtd |jd |jd d|jd dkrutd |jd|jd|||||S)z Args: input: the shape should be BNH[WD]. target: the shape should be BNH[WD]. mask: the shape should be B1H[WD] or 11H[WD]. Nz+No mask value specified for the MaskedLoss.zDim of input (z) is different from mask (z).rzBatch size of mask (z!) must be one or equal to input (zMask (z) must have only one channel.zSpatial size of input ()warningswarnrdimshaper)rrrrrrrforward2s  " zMaskedLoss.forward)rr r rr rr r )N)rrrrrrr r)__name__ __module__ __qualname____doc__rr$ __classcell__rrrrrs) __future__rrr collections.abcrtypingrrtorchtorch.nn.modules.lossr__all__rrrrrs