
    ёi                    d    S SK Jr  S SKJr  S SKrS SKJr  SS jr " S S\R                  5      rg)	    )annotations)OrderedDictN)nnc                j    Uc  Un[        U[        XS-  -   5      U-  U-  5      nUSU -  :  a  X1-  nU$ )a  
This function ensures that all layers have a channel number that is divisible by divisor.
You can also see at https://github.com/keras-team/keras/blob/8ecef127f70db723c158dbe9ed3268b3d610ab55/keras/applications/mobilenet_v2.py#L505

Args:
    divisor (int, optional): The divisor for number of channels. Default: 8.
    min_value (int, optional): The minimum value of number of channels, if it is None,
        the default is divisor. Default: None.
   g?)maxint)vdivisor	min_valuenew_vs       [/var/www/html/banglarbhumi/venv/lib/python3.13/site-packages/paddle/vision/models/_utils.py_make_divisibler      sH     		3qQ;/7:WDEEsQwL    c                  B   ^  \ rS rSr% SrS\S'   SU 4S jjrS rSrU =r	$ )	IntermediateLayerGetter)   a   
Layer wrapper that returns intermediate layers from a model.

It has a strong assumption that the layers have been registered into the model in the
same order as they are used. This means that one should **not** reuse the same nn.Layer
twice in the forward if you want this to work.

Additionally, it is only able to query sublayer that are directly assigned to the model.
So if `model` is passed, `model.feature1` can be returned, but not `model.feature1.layer2`.

Args:

    model (nn.Layer): Model on which we will extract the features.
    return_layers (Dict[name, new_name]): A dict containing the names of the layers for
    which the activations will be returned as the key of the dict, and the value of the
    dict is the name of the returned activation (which the user can specify).

Examples:

    .. code-block:: python

        >>> import paddle
        >>> m = paddle.vision.models.resnet18(pretrained=False)

        >>> # extract layer1 and layer3, giving as names `feat1` and feat2`
        >>> new_m = paddle.vision.models._utils.IntermediateLayerGetter(m,
        ...     {'layer1': 'feat1', 'layer3': 'feat2'})
        >>> out = new_m(paddle.rand([1, 3, 224, 224]))
        >>> print([(k, v.shape) for k, v in out.items()])
        [('feat1', [1, 64, 56, 56]), ('feat2', [1, 256, 14, 14])]
dict[str, str]return_layersc                  > [        U5      R                  UR                  5        VVs/ s H  u  p4UPM	     snn5      (       d  [        S5      eUnUR	                  5        VVs0 s H  u  pg[        U5      [        U5      _M     nnn[        5       nUR                  5        H  u  p9XU'   X2;   a  X#	 U(       a  M    O   [        T
U ]!  U5        XPl	        g s  snnf s  snnf )Nz&return_layers are not present in model)
setissubsetnamed_children
ValueErroritemsstrr   super__init__r   )selfmodelr   name_orig_return_layerskr
   layersmodule	__class__s             r   r    IntermediateLayerGetter.__init__L   s    =!**!&!5!5!78!7gdT!78
 
 EFF*4A4G4G4IJ4IDAQQ4IJ!002LD!4L$!' = 3 	 / 9 Ks   C
$!Cc                   [        5       nU R                  5        H  u  p4[        U[        R                  5      (       a  UR
                  S:X  d]  [        UR                  5       5      S:  aW  [        UR                  5       S   [        R                  5      (       a'  UR
                  S:X  a  [        R                  " US5      nU" U5      nX0R                  ;   d  M  U R                  U   nXU'   M     U$ )N   r      )r   r   
isinstancer   Linearndimlen	sublayerspaddleflattenr   )r   xoutr!   r&   out_names         r   forwardIntermediateLayerGetter.forward^   s    m JJLLD6299--!&&A+F$$&'!+v//1!4bii@@FFaKNN1a(q	A)))--d3 !H ) 
r   )r   )r    znn.Layerr   r   returnNone)
__name__
__module____qualname____firstlineno____doc____annotations__r   r6   __static_attributes____classcell__)r'   s   @r   r   r   )   s     @ "!0$ r   r   )   N)	
__future__r   collectionsr   r1   r   r   	LayerDictr    r   r   <module>rG      s*    # #  &Cbll Cr   