

from collections import OrderedDict
from typing import Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


_a			=       logging.get_logger(__name__)

_a			=       {
    '''apple/mobilevitv2-1.0''': '''https://huggingface.co/apple/mobilevitv2-1.0/resolve/main/config.json''',
}






class 							A_			(		snake_case__ ):
     _lowercase      :					str       =     'mobilevitv2'


     def __init__(							self      :		Optional[int]      ,  UpperCAmelCase      :		List[Any]=3      ,  UpperCAmelCase      :		Union[str, Any]=2_5_6      ,  UpperCAmelCase      :		Dict=2      ,  UpperCAmelCase      :		str=2.0      ,  UpperCAmelCase      :		List[str]="swish"      ,  UpperCAmelCase      :		Union[str, Any]=3      ,  UpperCAmelCase      :		str=3_2      ,  UpperCAmelCase      :		Dict=0.1      ,  UpperCAmelCase      :		str=0.02      ,  UpperCAmelCase      :		Optional[int]=1E-5      ,  UpperCAmelCase      :		str=5_1_2      ,  UpperCAmelCase      :		Any=[6, 1_2, 1_8]      ,  UpperCAmelCase      :		str=0.1      ,  UpperCAmelCase      :		Optional[Any]=2_5_5      ,  UpperCAmelCase      :		Optional[Any]=[2, 4, 3]      ,  UpperCAmelCase      :		str=[1_2_8, 1_9_2, 2_5_6]      ,  UpperCAmelCase      :		Optional[int]=1.0      ,  UpperCAmelCase      :		str=2      ,  UpperCAmelCase      :		Any=0.0      ,  UpperCAmelCase      :		Tuple=0.0      ,  **UpperCAmelCase      :		Dict      ,  )							->     Optional[Any]:
      super().__init__(**UpperCAmelCase )

      __lowerCAmelCase:       Dict            =				num_channels
      __lowerCAmelCase:       Union[str, Any]            =				image_size
      __lowerCAmelCase:       Any            =				patch_size
      __lowerCAmelCase:       Any            =				expand_ratio
      __lowerCAmelCase:       Dict            =				hidden_act
      __lowerCAmelCase:       Optional[int]            =				conv_kernel_size
      __lowerCAmelCase:       Any            =				output_stride
      __lowerCAmelCase:       Dict            =				initializer_range
      __lowerCAmelCase:       Optional[Any]            =				layer_norm_eps
      __lowerCAmelCase:       Optional[Any]            =				n_attn_blocks
      __lowerCAmelCase:       Union[str, Any]            =				base_attn_unit_dims
      __lowerCAmelCase:       List[Any]            =				width_multiplier
      __lowerCAmelCase:       Tuple            =				ffn_multiplier
      __lowerCAmelCase:       Tuple            =				ffn_dropout
      __lowerCAmelCase:       Union[str, Any]            =				attn_dropout
      __lowerCAmelCase:       int            =				classifier_dropout_prob

      # decode head attributes for semantic segmentation
      __lowerCAmelCase:       List[str]            =				aspp_out_channels
      __lowerCAmelCase:       Optional[int]            =				atrous_rates
      __lowerCAmelCase:       Optional[int]            =				aspp_dropout_prob
      __lowerCAmelCase:       Union[str, Any]            =				semantic_loss_ignore_index







class 							A_			(		snake_case__ ):
     _lowercase      :					Tuple       =     version.parse('1.11' )


     @property
     def   UpperCAmelCase  (							self      :		Any )							->     Mapping[str, Mapping[int, str]]:
      return OrderedDict([('pixel_values', {0: 'batch', 1: 'num_channels', 2: 'height', 3: 'width'})] )


     @property
     def   UpperCAmelCase  (							self      :		int )							->     Mapping[str, Mapping[int, str]]:
      if self.task == "image-classification":
       return OrderedDict([('logits', {0: 'batch'})] )
      else:
       return OrderedDict([('last_hidden_state', {0: 'batch'}), ('pooler_output', {0: 'batch'})] )


     @property
     def   UpperCAmelCase  (							self      :		Optional[Any] )							->     float:
      return 1E-4








from __future__ import annotations

from collections.abc import Iterable
from dataclasses import dataclass
from typing import Any






class 							A_			:
     _lowercase      :					Any       =     ('_front', '_back', '_len')






     @dataclass
     class 							A_			:
          _lowercase      :					Any       =     None
          _lowercase      :					Deque._Node | None       =     None
          _lowercase      :					Deque._Node | None       =     None







     class 							A_			:
          _lowercase      :					Optional[Any]       =     ('_cur',)


          def __init__(							self      :		Any      ,  UpperCAmelCase      :		Deque._Node | None )							->     None:
           __lowerCAmelCase:       int            =				cur


          def __iter__(							self      :		int )							->     Deque._Iterator:
           return self


          def   UpperCAmelCase  (							self      :		Optional[Any] )							->     Any:
           if self._cur is None:
            # finished iterating
            raise StopIteration
           __lowerCAmelCase:       Optional[Any]            =				self._cur.val
           __lowerCAmelCase:       List[Any]            =				self._cur.next_node

           return val







     def __init__(							self      :		Any      ,  UpperCAmelCase      :		Iterable[Any] | None = None )							->     None:
      __lowerCAmelCase:       Any            =				None
      __lowerCAmelCase:       Any            =				None
      __lowerCAmelCase:       int            =				0

      if iterable is not None:
       # append every value to the deque
       for val in iterable:
        self.append(UpperCAmelCase )


     def   UpperCAmelCase  (							self      :		List[str]      ,  UpperCAmelCase      :		Any )							->     None:
      __lowerCAmelCase:       Union[str, Any]            =				self._Node(UpperCAmelCase      ,  UpperCAmelCase      ,  UpperCAmelCase )
      if self.is_empty():
       # front = back
       __lowerCAmelCase:       int            =				node
       __lowerCAmelCase:       List[Any]            =				1
      else:
       # connect nodes
       __lowerCAmelCase:       Optional[Any]            =				node
       __lowerCAmelCase:       str            =				self._back
       __lowerCAmelCase:       Optional[int]            =				node  # assign new back to the new node

       self._len += 1

       # make sure there were no errors
       assert not self.is_empty(), "Error on appending value."


     def   UpperCAmelCase  (							self      :		Optional[int]      ,  UpperCAmelCase      :		Any )							->     None:
      __lowerCAmelCase:       int            =				self._Node(UpperCAmelCase      ,  UpperCAmelCase      ,  UpperCAmelCase )
      if self.is_empty():
       # front = back
       __lowerCAmelCase:       Union[str, Any]            =				node
       __lowerCAmelCase:       str            =				1
      else:
       # connect nodes
       __lowerCAmelCase:       Dict            =				self._front
       __lowerCAmelCase:       Optional[int]            =				node
       __lowerCAmelCase:       Any            =				node  # assign new front to the new node

       self._len += 1

       # make sure there were no errors
       assert not self.is_empty(), "Error on appending value."


     def   UpperCAmelCase  (							self      :		Union[str, Any]      ,  UpperCAmelCase      :		Iterable[Any] )							->     None:
      for val in iterable:
       self.append(UpperCAmelCase )


     def   UpperCAmelCase  (							self      :		List[str]      ,  UpperCAmelCase      :		Iterable[Any] )							->     None:
      for val in iterable:
       self.appendleft(UpperCAmelCase )


     def   UpperCAmelCase  (							self      :		Dict )							->     Any:
      assert not self.is_empty(), "Deque is empty."

      __lowerCAmelCase:       Optional[int]            =				self._back
      __lowerCAmelCase:       Optional[Any]            =				self._back.prev_node  # set new back
      # drop the last node - python will deallocate memory automatically
      __lowerCAmelCase:       Optional[int]            =				None

      self._len -= 1

      return topop.val


     def   UpperCAmelCase  (							self      :		Dict )							->     Any:
      assert not self.is_empty(), "Deque is empty."

      __lowerCAmelCase:       Optional[Any]            =				self._front
      __lowerCAmelCase:       Optional[Any]            =				self._front.next_node  # set new front and drop the first node
      __lowerCAmelCase:       int            =				None

      self._len -= 1

      return topop.val


     def   UpperCAmelCase  (							self      :		Dict )							->     bool:
      return self._front is None


     def __len__(							self      :		List[Any] )							->     int:
      return self._len


     def __eq__(							self      :		Union[str, Any]      ,  UpperCAmelCase      :		object )							->     bool:

      if not isinstance(UpperCAmelCase      ,  UpperCAmelCase ):
       return NotImplemented

      __lowerCAmelCase:       List[Any]            =				self._front
      __lowerCAmelCase:       Dict            =				other._front

      # if the length of the dequeues are not the same, they are not equal
      if len(self ) != len(UpperCAmelCase ):
       return False

      while me is not None and oth is not None:
       # compare every value
       if me.val != oth.val:
        return False
       __lowerCAmelCase:       Optional[Any]            =				me.next_node
       __lowerCAmelCase:       Optional[Any]            =				oth.next_node

      return True


     def __iter__(							self      :		Tuple )							->     Deque._Iterator:
      return Deque._Iterator(self._front )


     def __repr__(							self      :		Optional[Any] )							->     str:
      __lowerCAmelCase:       Union[str, Any]            =				[]
      __lowerCAmelCase:       Optional[int]            =				self._front
      while aux is not None:
       # append the values in a list to display
       values_list.append(aux.val )
       __lowerCAmelCase:       Any            =				aux.next_node

      return F'''[{', '.join(repr(UpperCAmelCase ) for val in values_list )}]'''


if __name__ == "__main__":
  import doctest

  doctest.testmod()





