o
    0i                     @  sJ   d dl mZ d dlmZ G dd dZG dd deZG dd deZd	S )
    )annotations)ExchangeObjectc                   @  s4   e Zd ZdZddddZddd	d
ZddddZdS )
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.
    Nextradict | NonereturnNonec                 C     dS )z
        Call to initialize the ClientAlgo class.

        Args:
            extra: optional extra information, e.g. dict of `ExtraItems.CLIENT_NAME` and/or `ExtraItems.APP_ROOT`.
        N selfr   r
   r
   ]/home/dell461/cl/sdc2/last_ska_mid/HISourceFinder-master-l/src/monai/fl/client/client_algo.py
initialize      zBaseClient.initializec                 C  r	   )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'   r   zBaseClient.finalizec                 C  r	   )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   abort0   s   zBaseClient.abortN)r   r   r   r   )__name__
__module____qualname____doc__r   r   r   r
   r
   r
   r   r      s
    		r   c                   @  s   e Zd Zdd	ddZdS )
ClientAlgoStatsNr   r   r   r   c                 C     t d| jj d)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__r   r   r
   r
   r   get_data_stats=   s   zClientAlgoStats.get_data_statsr   r   r   r   r   )r   r   r   r   r
   r
   r
   r   r   ;   s    r   c                   @  s4   e Zd ZdZddd	d
ZddddZddddZdS )
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.
    Ndatar   r   r   r   r   c                 C  r   )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
        r   r   r   r   r!   r   r
   r
   r   trainj      zClientAlgo.trainc                 C  r   )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
            )

        r   r   r   r   r
   r
   r   get_weightsw   s   zClientAlgo.get_weightsc                 C  r   )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.
        r   r   r   r"   r
   r
   r   evaluate   r$   zClientAlgo.evaluater   )r!   r   r   r   r   r   r   )r!   r   r   r   r   r   )r   r   r   r   r#   r%   r&   r
   r
   r
   r   r    [   s
    r    N)
__future__r   Zmonai.fl.utils.exchange_objectr   r   r   r    r
   r
   r
   r   <module>   s
   * 