U Ph @s,ddlmZddlmZGdddeZdS)) annotations) WeightTypecseZdZdZdddddddfdd Zedd Zejd d Zed d Zejd d ZeddZ e jddZ ddZ ddZ ddZ ddZ ddZZS)ExchangeObjectaP Contains the information shared between client and server. Args: weights: model weights. optim: optimizer weights. metrics: evaluation metrics. weight_type: type of weights (see monai.fl.utils.constants.WeightType). statistics: training statistics, i.e. number executed iterations. Nz dict | NonezWeightType | None)weightsoptimmetrics weight_type statisticscs2t||_||_||_||_||_i|_dSN)super__init__rrrrr _summary)selfrrrrr  __class__S/home/dell461/cl/sdc2/HISourceFinder-master-l/src/monai/fl/utils/exchange_object.pyr s zExchangeObject.__init__cCs|jSr )_metricsrrrrr-szExchangeObject.metricscCs.|dk r$t|ts$tdt|||_dS)Nz1Expected metrics to be of type dict but received ) isinstancedict ValueErrortyper)rrrrrr1s cCs|jSr ) _statisticsrrrrr 8szExchangeObject.statisticscCs.|dk r$t|ts$tdt|||_dS)Nz4Expected statistics to be of type dict but received )rrrrr)rr rrrr <s cCs|jSr ) _weight_typerrrrrCszExchangeObject.weight_typecCs:|dk r0|tjtjfkr0tdtjdtj||_dS)Nz"Expected weight type to be either z or )rZWEIGHTSZ WEIGHT_DIFFrr)rrrrrrGscCs|js dS|jsdSdS)NFT)rrrrrris_valid_weightsNs zExchangeObject.is_valid_weightscCsF|rBt|trt||j|<n$t|tr4||j|<nt||j|<dSr )rrlenr rr)rkeyvaluerrr_add_to_summaryUs    zExchangeObject._add_to_summarycCsP|j|tdddddg|j|j|j|j|jgD]\}}|||q4|jS)Nrrrrr ) r updateziprrrrr r)rkvrrrsummary^s   zExchangeObject.summarycCs t|Sr strr$rrrr__repr__gszExchangeObject.__repr__cCs t|Sr r%rrrr__str__jszExchangeObject.__str__)NNNNN)__name__ __module__ __qualname____doc__r propertyrsetterr rrrr$r'r( __classcell__rrrrrs0         rN) __future__rZmonai.fl.utils.constantsrrrrrrr s