o 0 i@sJddlmZddlmZGdddZGdddeZGdddeZd S) ) annotations)ExchangeObjectc@s4eZdZdZd dddZd dd d Zd dd d ZdS) BaseClienta Provide an abstract base class to allow the client to return summary statistics of the data. To define a new stats script, subclass this class and implement the following abstract methods:: - self.get_data_stats() initialize(), abort(), and finalize() -- inherited from `ClientAlgoStats`; can be optionally be implemented to help with lifecycle management of the class object. Nextra dict | NonereturnNonecCdS)z Call to initialize the ClientAlgo class. Args: extra: optional extra information, e.g. dict of `ExtraItems.CLIENT_NAME` and/or `ExtraItems.APP_ROOT`. Nselfrr r ]/home/dell461/cl/sdc2/last_ska_mid/HISourceFinder-master-l/src/monai/fl/client/client_algo.py initializezBaseClient.initializecCr )z Call to finalize the ClientAlgo class. Args: extra: Dict with additional information that can be provided by the FL system. Nr r r r r finalize'rzBaseClient.finalizecCr )z Call to abort the ClientAlgo training or evaluation. Args: extra: Dict with additional information that can be provided by the FL system. Nr r r r r abort0szBaseClient.abortN)rrrr)__name__ __module__ __qualname____doc__rrrr r r r rs   rc@seZdZdd ddZdS) ClientAlgoStatsNrrrrcCtd|jjd)a Get summary statistics about the local data. Args: extra: Dict with additional information that can be provided by the FL system. For example, requested statistics. Returns: ExchangeObject: summary statistics. Extra dict example:: requested_stats = { FlStatistics.STATISTICS: metrics, FlStatistics.NUM_OF_BINS: num_of_bins, FlStatistics.BIN_RANGES: bin_ranges } Returned ExchangeObject example:: ExchangeObject( statistics = {...} ) Subclass  must implement this method.NotImplementedError __class__rr r r r get_data_stats=szClientAlgoStats.get_data_statsrrrrr)rrrrr r r r r;src@s4eZdZdZddd d Zddd d Zddd dZdS) ClientAlgoa Provide an abstract base class for defining algo to run on any platform. To define a new algo script, subclass this class and implement the following abstract methods: - self.train() - self.get_weights() - self.evaluate() - self.get_data_stats() (optional, inherited from `ClientAlgoStats`) initialize(), abort(), and finalize() - inherited from `ClientAlgoStats` - can be optionally be implemented to help with lifecycle management of the class object. NdatarrrrrcCr)a. Train network and produce new network from train data. Args: data: ExchangeObject containing current network weights to base training on. extra: Dict with additional information that can be provided by the FL system. Returns: None rrrr r!rr r r trainj zClientAlgo.traincCr)a* Get current local weights or weight differences. Args: extra: Dict with additional information that can be provided by the FL system. Returns: ExchangeObject: current local weights or weight differences. `ExchangeObject` example: .. code-block:: python ExchangeObject( weights = self.trainer.network.state_dict(), optim = None, # could be self.optimizer.state_dict() weight_type = WeightType.WEIGHTS ) rrrr r r r get_weightswszClientAlgo.get_weightscCr)a< Get evaluation metrics on test data. Args: data: ExchangeObject with network weights to use for evaluation. extra: Dict with additional information that can be provided by the FL system. Returns: metrics: ExchangeObject with evaluation metrics. rrrr"r r r evaluater$zClientAlgo.evaluater)r!rrrrrr)r!rrrrr)rrrrr#r%r&r r r r r [s   r N) __future__rZmonai.fl.utils.exchange_objectrrrr r r r r s *