o  i@sddlmZddlmZddlZddlmZddlm Z ddl m Z ddl m Z ddlmZd d lmZmZd d lmZmZmZgd ZGdddeeZGdddeeZGdddeeZeZZeZZeZZ dS)) annotations)HashableN)KeysCollection)NdarrayOrTensor)get_track_meta)convert_to_tensor) ensure_tuple) MapTransformRandomizableTransform)CutMixCutOutMixUp) MixUpdMixUpD MixUpDictCutMixdCutMixD CutMixDictCutOutdCutOutD CutOutDictcs:eZdZdZ ddddZddfdd ZddZZS)rz Dictionary-based version :py:class:`monai.transforms.MixUp`. Notice that the mixup transformation will be the same for all entries for consistency, i.e. images and labels must be applied the same augmenation. ?Fkeysr batch_sizeintalphafloatallow_missing_keysboolreturnNonecCst|||t|||_dSN)r __init__rmixup)selfrrrrr'l/home/dell461/cl/sdc2/last_ska_mid/HISourceFinder-master-l/src/monai/transforms/regularization/dictionary.pyr$&szMixUpd.__init__Nseed int | Nonestatenp.random.RandomState | Nonec t|||j|||Sr#)superset_random_stater%r&r)r+ __class__r'r(r/,zMixUpd.set_random_statecCs>t|}|jd||D] }|j||dd||<q|S)NF randomize)dictr%r5 key_iterator)r&datadkr'r'r(__call__1s  zMixUpd.__call__)rF) rrrrrrrr r!r"NN)r)r*r+r,r!r__name__ __module__ __qualname____doc__r$r/r; __classcell__r'r'r1r(rs  rcsBeZdZdZ   ddfdd Zddfdd ZddZZS)ra Dictionary-based version :py:class:`monai.transforms.CutMix`. Notice that the mixture weights will be the same for all entries for consistency, i.e. images and labels must be aggregated with the same weights, but the random crops are not. NrFrrrr label_keysKeysCollection | Nonerrrr r!r"cs:t||t|||_|durt||_dSg|_dSr#)r.r$r mixerrrC)r&rrrCrrr1r'r(r$Cs  zCutMixd.__init__r)r*r+r,cr-r#)r.r/rEr0r1r'r(r/Or3zCutMixd.set_random_statecCst|}||}|dkrt|td}|S|j|||||jD]"\}}|j||||ddd}|d||<||vrG|d||<q%|S)Nr' track_metaFr4rr ) r6 first_keyrrrEr5r7rCget)r&r8r9rHoutkey label_keyretr'r'r(r;Ts   zCutMixd.__call__)NrF) rrrrrCrDrrrr r!r"r<)r)r*r+r,r!rr=r'r'r1r(r:s  rcs<eZdZdZddfd d Zddfdd ZddZZS)rz Dictionary-based version :py:class:`monai.transforms.CutOut`. Notice that the cutout is different for every entry in the dictionary. Frrrrrr r!r"cst||t||_dSr#)r.r$rcutout)r&rrrr1r'r(r$jszCutOutd.__init__Nr)r*r+r,cr-r#)r.r/rNr0r1r'r(r/nr3zCutOutd.set_random_statecCsft|}||}|dkrt|td}|S|j||||D] }|j||dd||<q#|S)Nr'rFFr4)r6rHrrrNr5r7)r&r8r9rHrJr:r'r'r(r;ss zCutOutd.__call__)F)rrrrrr r!r"r<)r)r*r+r,r!rr=r'r'r1r(rcs r)! __future__rcollections.abcrnumpynp monai.configrmonai.config.type_definitionsrmonai.data.meta_objr monai.utilsrmonai.utils.miscr transformr r arrayr rr__all__rrrrrrrrrr'r'r'r(s"      )