U
    Ph                     @  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                   @  sF   e Zd ZdZddddddZdddddd	Zdd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dict | NoneNoneextrareturnc                 C  s   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
   P/home/dell461/cl/sdc2/HISourceFinder-master-l/src/monai/fl/client/client_algo.py
initialize   s    zBaseClient.initializec                 C  s   dS )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'   s    zBaseClient.finalizec                 C  s   dS )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)N)N)__name__
__module____qualname____doc__r   r   r   r
   r
   r
   r   r      s   		r   c                   @  s   e Zd ZddddddZdS )ClientAlgoStatsNr   r   r   c                 C  s   t d| jj ddS )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.NNotImplementedError	__class__r   r   r
   r
   r   get_data_stats=   s    zClientAlgoStats.get_data_stats)N)r   r   r   r   r
   r
   r
   r   r   ;   s   r   c                   @  sJ   e Zd ZdZdddddddZdddd	d
dZddd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.
    Nr   r   r   )datar   r	   c                 C  s   t d| jj ddS )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   Nr   r   r   r   r
   r
   r   trainj   s    zClientAlgo.trainr   c                 C  s   t d| jj ddS )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   Nr   r   r
   r
   r   get_weightsw   s    zClientAlgo.get_weightsc                 C  s   t d| jj ddS )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   Nr   r   r
   r
   r   evaluate   s    zClientAlgo.evaluate)N)N)N)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   * 