
    ёi                        S SK Jr  S SKrS SKrS SKJr  S SKJrJrJ	r	  \(       a  S SK
Jr  SSKJr   " S S	\R                  S
9r " S S\5      r\r    SS jrg)    )annotationsN)partial)TYPE_CHECKINGAnyCallable)Layer   )BaseQuanterc                  n    \ rS rSrS
S jr\S 5       r\S 5       r\R                  S 5       r
S rS rSrg	)ClassWithArguments   c                    Xl         X l        g N_args_kwargs)selfargskwargss      [/var/www/html/banglarbhumi/venv/lib/python3.13/site-packages/paddle/quantization/factory.py__init__ClassWithArguments.__init__   s    
    c                    U R                   $ r   )r   r   s    r   r   ClassWithArguments.args    s    zzr   c                    U R                   $ r   )r   r   s    r   r   ClassWithArguments.kwargs$   s    ||r   c                    g r    r   s    r   
_get_classClassWithArguments._get_class(   s    r   c           
         SR                  [        U R                  5      U R                  R	                  5        VVs/ s H  u  pU SU 3PM     snn-   5      nU R
                  R                   SU S3$ s  snnf )N,=())joinlistr   r   items	__class____name__)r   kvargs_strs       r   __str__ClassWithArguments.__str__,   sp    88Odkk6G6G6IJ6Ida!AaSz6IJJ
 ..))*!H:Q77 Ks   A6c                "    U R                  5       $ r   )r0   r   s    r   __repr__ClassWithArguments.__repr__2   s    ||~r   r   Nr   r   r   r   returnNone)r,   
__module____qualname____firstlineno__r   propertyr   r   abcabstractmethodr!   r0   r3   __static_attributes__r    r   r   r   r      sS         	 8r   r   )	metaclassc                  :   ^  \ rS rSrSrSU 4S jjrSS jrSrU =r$ )QuanterFactory6   zf
The factory holds the quanter's class information and
the arguments used to create quanter instance.
c                4   > [         TU ]  " U0 UD6  S U l        g r   )superr   partial_class)r   r   r   r+   s      r   r   QuanterFactory.__init__<   s    $)&)!r   c                    U R                   c6  [        U R                  5       /U R                  Q70 U R                  D6U l         U R                  U5      $ )z1
Create an instance of quanter for target layer.
)rE   r   r!   r   r   )r   layers     r   	_instanceQuanterFactory._instance@   sR     %!(!"$(II"15"D !!%((r   )rE   r5   )rH   r   r6   r
   )	r,   r8   r9   r:   __doc__r   rI   r>   __classcell__)r+   s   @r   rA   rA   6   s    
") )r   rA   c                   ^  SU 4S jjnU$ )a  
Annotation to declare a factory class for quanter.

Args:
    class_name (str): The name of factory class to be declared.

Examples:
    .. code-block:: python

        >>> # type: ignore
        >>> # doctest: +SKIP('need 2 file to run example')
        >>> # Given codes in ./customized_quanter.py
        >>> from paddle.quantization import quanter
        >>> from paddle.quantization import BaseQuanter
        >>> @quanter("CustomizedQuanter")
        >>> class CustomizedQuanterLayer(BaseQuanter):
        ...     def __init__(self, arg1, kwarg1=None):
        ...         pass

        >>> # Used in ./test.py
        >>> # from .customized_quanter import CustomizedQuanter
        >>> from paddle.quantization import QuantConfig
        >>> arg1_value = "test"
        >>> kwarg1_value = 20
        >>> quanter = CustomizedQuanter(arg1_value, kwarg1=kwarg1_value)
        >>> q_config = QuantConfig(activation=quanter, weight=quanter)

c           	       > SU R                    SU R                   SU R                   SU R                   S3	n[        U5        [        R                  " 5       S   n[        R
                  " US   5      n[        T[        4[        5       S   [        5       S	   S
.5      n[        UTU5        SUR                  ;   a  UR                  R                  T5        U $ )Nz
def init_function(self, *args, **kwargs):
    super(type(self), self).__init__(*args, **kwargs)
    import importlib
    module = importlib.import_module("z#")
    my_class = getattr(module, "z")
    globals()["z7"] = my_class
def get_class_function(self):
    return z[
locals()["init_function"]=init_function
locals()["get_class_function"]=get_class_function
r	   r   init_functionget_class_function)r   r!   __all__)r8   r,   execinspectstack	getmoduletyperA   localssetattr__dict__rQ   append)target_classinit_function_strfrmmod	new_class
class_names        r   wrapperquanter.<locals>.wrappern   s    !' (4'>'>&? @!!-!6!6 7 8%%& '!!" # 	mmoa A'"H_5$h';<
	 	Z+$KKz*r   )r[   type[BaseQuanter]r6   rc   r    )r`   ra   s   ` r   quanterrd   N   s    @< Nr   )r`   strr6   z0Callable[[type[BaseQuanter]], type[BaseQuanter]])
__future__r   r<   rS   	functoolsr   typingr   r   r   	paddle.nnr   base_quanterr
   ABCMetar   rA   ObserverFactoryrd   r    r   r   <module>rm      s[    # 
   / /)3;; 6)' )* !>>5>r   