o  i @s2ddlmZddlZddlmZ ddddZdS)) annotationsNTinput torch.Tensortarget reduce_axis list[int]ordint soft_labelbool decoupledreturn/tuple[torch.Tensor, torch.Tensor, torch.Tensor]c Cs|dkr;|s;tj|||d}|r$tj||d|}tj||d|}nZtj|d||d}tjd|||d}nCtj|||d} tj|||d} tj||||d} |dkrntj| |d} tj| |d} tj| |d} | | | d}| |}| |}|||fS)a Args: input: the shape should be BNH[WD], where N is the number of classes. target: the shape should be BNH[WD] or B1H[WD], where N is the number of classes. reduce_axis: the axis to be reduced. ord: the order of the vector norm. soft_label: whether the target contains non-binary values (soft labels) or not. If True a soft label formulation of the loss will be used. decoupled: whether the input and the target should be decoupled when computing fp and fn. Only for the original implementation when soft_label is False. Adapted from: https://github.com/zifuwanggg/JDTLosses )dim)rr)exponent)torchsumLA vector_normpow) rrrrr r tpfpfnZpred_oground_o differencerT/home/dell461/cl/sdc2/last_ska_mid/HISourceFinder-master-l/src/monai/losses/utils.pycompute_tp_fp_fns$  r)T)rrrrrrrr r r r r r r) __future__rrZ torch.linalglinalgrrrrrrs