


from math import factorial


class   a__	:

       def __init__(   self      :     int      ,							lowerCamelCase_      :     Dict      ,							lowerCamelCase_      :     str    ):
            a_    :     Any										=    real
            if isinstance(lowerCamelCase_      ,							lowerCamelCase_    ):
                 a_    :     str										=    [1] * rank
            else:
                 a_    :     Optional[Any]										=    rank

       def __repr__(   self      :     Any    ):
            return (
                F'''{self.real}+'''
                F'''{"+".join(str(lowerCamelCase_    )+"E"+str(n+1    )for n,dual in enumerate(self.duals    )    )}'''
            )

       def 						UpperCAmelCase(   self      :     Optional[int]    ):
            a_    :     Optional[Any]										=    self.duals.copy()
            while cur[-1] == 0:
                 cur.pop(-1    )
            return Dual(self.real      ,							lowerCamelCase_    )

       def __add__(   self      :     str      ,							lowerCamelCase_      :     List[Any]    ):
            if not isinstance(lowerCamelCase_      ,							lowerCamelCase_    ):
                 return Dual(self.real + other      ,							self.duals    )
            a_    :     Any										=    self.duals.copy()
            a_    :     Optional[int]										=    other.duals.copy()
            if len(lowerCamelCase_    ) > len(lowerCamelCase_    ):
                 o_dual.extend([1] * (len(lowerCamelCase_    ) - len(lowerCamelCase_    ))    )
            elif len(lowerCamelCase_    ) < len(lowerCamelCase_    ):
                 s_dual.extend([1] * (len(lowerCamelCase_    ) - len(lowerCamelCase_    ))    )
            a_    :     List[Any]										=    []
            for i in range(len(lowerCamelCase_    )    ):
                 new_duals.append(s_dual[i] + o_dual[i]    )
            return Dual(self.real + other.real      ,							lowerCamelCase_    )

       lowerCamelCase__:     Optional[Any]							    =     __add__

       def __sub__(   self      :     Union[str, Any]      ,							lowerCamelCase_      :     List[Any]    ):
            return self + other * -1

       def __mul__(   self      :     int      ,							lowerCamelCase_      :     List[str]    ):
            if not isinstance(lowerCamelCase_      ,							lowerCamelCase_    ):
                 a_    :     Dict										=    []
                 for i in self.duals:
                      new_duals.append(i * other    )
                 return Dual(self.real * other      ,							lowerCamelCase_    )
            a_    :     int										=    [0] * (len(self.duals    ) + len(other.duals    ) + 1)
            for i, item in enumerate(self.duals    ):
                 for j, jtem in enumerate(other.duals    ):
                      new_duals[i + j + 1] += item * jtem
            for k in range(len(self.duals    )    ):
                 new_duals[k] += self.duals[k] * other.real
            for index in range(len(other.duals    )    ):
                 new_duals[index] += other.duals[index] * self.real
            return Dual(self.real * other.real      ,							lowerCamelCase_    )

       lowerCamelCase__:     Optional[Any]							    =     __mul__

       def __truediv__(   self      :     int      ,							lowerCamelCase_      :     str    ):
            if not isinstance(lowerCamelCase_      ,							lowerCamelCase_    ):
                 a_    :     List[Any]										=    []
                 for i in self.duals:
                      new_duals.append(i / other    )
                 return Dual(self.real / other      ,							lowerCamelCase_    )
            raise ValueError

       def __floordiv__(   self      :     int      ,							lowerCamelCase_      :     Tuple    ):
            if not isinstance(lowerCamelCase_      ,							lowerCamelCase_    ):
                 a_    :     Union[str, Any]										=    []
                 for i in self.duals:
                      new_duals.append(i // other    )
                 return Dual(self.real // other      ,							lowerCamelCase_    )
            raise ValueError

       def __pow__(   self      :     Tuple      ,							lowerCamelCase_      :     Any    ):
            if n < 0 or isinstance(lowerCamelCase_      ,							lowerCamelCase_    ):
                 raise ValueError("""power must be a positive integer"""    )
            if n == 0:
                 return 1
            if n == 1:
                 return self
            a_    :     Optional[int]										=    self
            for _ in range(n - 1    ):
                 x *= self
            return x



def  _a			(						__UpperCamelCase  ,  __UpperCamelCase  ,  __UpperCamelCase ):
     if not callable(__UpperCamelCase ):
          raise ValueError("""differentiate() requires a function as input for func""" )
     if not isinstance(__UpperCamelCase  ,  (float, int) ):
          raise ValueError("""differentiate() requires a float as input for position""" )
     if not isinstance(__UpperCamelCase  ,  __UpperCamelCase ):
          raise ValueError("""differentiate() requires an int as input for order""" )
     a_    :     Tuple										=    Dual(__UpperCamelCase  ,  1 )
     a_    :     Tuple										=    func(__UpperCamelCase )
     if order == 0:
          return result.real
     return result.duals[order - 1] * factorial(__UpperCamelCase )


if __name__ == "__main__":
       import doctest

       doctest.testmod()



       def  _a			(						__UpperCamelCase ):
            return y**2 * y**4
       print(differentiate(f, 9, 2))







from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices


__lowerCamelCase        =     logging.get_logger(__name__)

__lowerCamelCase        =     {
    '''facebook/convnextv2-tiny-1k-224''': '''https://huggingface.co/facebook/convnextv2-tiny-1k-224/resolve/main/config.json''',
}


class   a__	(						lowerCAmelCase_						,       lowerCAmelCase_    ):
       lowerCamelCase__:     str							    =     """convnextv2"""

       def __init__(   self      :     Tuple      ,							lowerCamelCase_      :     str=3      ,							lowerCamelCase_      :     Tuple=4      ,							lowerCamelCase_      :     Any=4      ,							lowerCamelCase_      :     Optional[int]=None      ,							lowerCamelCase_      :     Optional[int]=None      ,							lowerCamelCase_      :     Optional[int]="gelu"      ,							lowerCamelCase_      :     Optional[Any]=0.0_2      ,							lowerCamelCase_      :     str=1E-12      ,							lowerCamelCase_      :     Dict=0.0      ,							lowerCamelCase_      :     Union[str, Any]=2_2_4      ,							lowerCamelCase_      :     Dict=None      ,							lowerCamelCase_      :     Optional[Any]=None      ,							**lowerCamelCase_      :     List[Any]      ,							):
            super().__init__(**lowerCamelCase_    )

            a_    :     Dict										=    num_channels
            a_    :     Optional[int]										=    patch_size
            a_    :     int										=    num_stages
            a_    :     Any										=    [9_6, 1_9_2, 3_8_4, 7_6_8] if hidden_sizes is None else hidden_sizes
            a_    :     Any										=    [3, 3, 9, 3] if depths is None else depths
            a_    :     Any										=    hidden_act
            a_    :     Dict										=    initializer_range
            a_    :     Optional[Any]										=    layer_norm_eps
            a_    :     int										=    drop_path_rate
            a_    :     Optional[Any]										=    image_size
            a_    :     Dict										=    ["""stem"""] + [F'''stage{idx}''' for idx in range(1      ,							len(self.depths    ) + 1    )]
            a_			,			a_    :     int										=    get_aligned_output_features_output_indices(
                out_features=lowerCamelCase_      ,							out_indices=lowerCamelCase_      ,							stage_names=self.stage_names    )



