





"""simple docstring"""






import numpy as np
from PIL import Image

def       __lowerCamelCase    (       SCREAMING_SNAKE_CASE,SCREAMING_SNAKE_CASE,SCREAMING_SNAKE_CASE							)		->       Tuple:






       """simple docstring"""




       _UpperCAmelCase     =     np.array(__A							)
       if arr.shape[0] != arr.shape[1]:
              raise ValueError('The input array is not a square matrix'							)
       _UpperCAmelCase     =     0
       _UpperCAmelCase     =     0
       _UpperCAmelCase     =     0
       _UpperCAmelCase     =     0

       # compute the shape of the output matrix
       _UpperCAmelCase     =     (arr.shape[0] - size) // stride + 1
       # initialize the output matrix with zeros of shape maxpool_shape
       _UpperCAmelCase     =     np.zeros((maxpool_shape, maxpool_shape)							)

       while i < arr.shape[0]:
              if i + size > arr.shape[0]:
                     # if the end of the matrix is reached, break
                     break
              while j < arr.shape[1]:
                     # if the end of the matrix is reached, break
                     if j + size > arr.shape[1]:
                            break
                     # compute the maximum of the pooling matrix
                     _UpperCAmelCase     =     np.max(arr[i : i + size, j : j + size]							)
                     # shift the pooling matrix by stride of column pixels
                     j += stride
                     mat_j += 1

              # shift the pooling matrix by stride of row pixels
              i += stride
              mat_i += 1

              # reset the column index to 0
              _UpperCAmelCase     =     0
              _UpperCAmelCase     =     0

       return updated_arr

def       __lowerCamelCase    (       SCREAMING_SNAKE_CASE,SCREAMING_SNAKE_CASE,SCREAMING_SNAKE_CASE							)		->       str:






       """simple docstring"""




       _UpperCAmelCase     =     np.array(__A							)
       if arr.shape[0] != arr.shape[1]:
              raise ValueError('The input array is not a square matrix'							)
       _UpperCAmelCase     =     0
       _UpperCAmelCase     =     0
       _UpperCAmelCase     =     0
       _UpperCAmelCase     =     0

       # compute the shape of the output matrix
       _UpperCAmelCase     =     (arr.shape[0] - size) // stride + 1
       # initialize the output matrix with zeros of shape avgpool_shape
       _UpperCAmelCase     =     np.zeros((avgpool_shape, avgpool_shape)							)

       while i < arr.shape[0]:
              # if the end of the matrix is reached, break
              if i + size > arr.shape[0]:
                     break
              while j < arr.shape[1]:
                     # if the end of the matrix is reached, break
                     if j + size > arr.shape[1]:
                            break
                     # compute the average of the pooling matrix
                     _UpperCAmelCase     =     int(np.average(arr[i : i + size, j : j + size]							)							)
                     # shift the pooling matrix by stride of column pixels
                     j += stride
                     mat_j += 1

              # shift the pooling matrix by stride of row pixels
              i += stride
              mat_i += 1
              # reset the column index to 0
              _UpperCAmelCase     =     0
              _UpperCAmelCase     =     0

       return updated_arr


# Main Function
if __name__ == "__main__":
    from doctest import testmod

    testmod(name='''avgpooling''', verbose=True)

    # Loading the image
    lowerCAmelCase_			=							Image.open('''path_to_image''')

    # Converting the image to numpy array and maxpooling, displaying the result
    # Ensure that the image is a square matrix

    Image.fromarray(maxpooling(np.array(image), size=3, stride=2)).show()

    # Converting the image to numpy array and averagepooling, displaying the result
    # Ensure that the image is a square matrix

    Image.fromarray(avgpooling(np.array(image), size=3, stride=2)).show()













"""simple docstring"""






from collections import OrderedDict
from typing import TYPE_CHECKING, Any, Mapping, Optional, Union

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


if TYPE_CHECKING:
    from ... import FeatureExtractionMixin, PreTrainedTokenizerBase, TensorType


lowerCAmelCase_			=							logging.get_logger(__name__)

lowerCAmelCase_			=							{
    '''microsoft/deberta-v2-xlarge''': '''https://huggingface.co/microsoft/deberta-v2-xlarge/resolve/main/config.json''',
    '''microsoft/deberta-v2-xxlarge''': '''https://huggingface.co/microsoft/deberta-v2-xxlarge/resolve/main/config.json''',
    '''microsoft/deberta-v2-xlarge-mnli''': (
        '''https://huggingface.co/microsoft/deberta-v2-xlarge-mnli/resolve/main/config.json'''
    ),
    '''microsoft/deberta-v2-xxlarge-mnli''': (
        '''https://huggingface.co/microsoft/deberta-v2-xxlarge-mnli/resolve/main/config.json'''
    ),
}



class 	lowerCAmelCase					(      snake_case							):
       lowerCAmelCase__						 =  """deberta-v2"""






       def __init__(   self    ,  a__=12_81_00    ,  a__=15_36    ,  a__=24    ,  a__=24    ,  a__=61_44    ,  a__="gelu"    ,  a__=0.1    ,  a__=0.1    ,  a__=5_12    ,  a__=0    ,  a__=0.02    ,  a__=1E-7    ,  a__=False    ,  a__=-1    ,  a__=0    ,  a__=True    ,  a__=None    ,  a__=0    ,  a__="gelu"    ,  **a__    ,  ):
              super().__init__(**a__     )

              _UpperCAmelCase     =     hidden_size
              _UpperCAmelCase     =     num_hidden_layers
              _UpperCAmelCase     =     num_attention_heads
              _UpperCAmelCase     =     intermediate_size
              _UpperCAmelCase     =     hidden_act
              _UpperCAmelCase     =     hidden_dropout_prob
              _UpperCAmelCase     =     attention_probs_dropout_prob
              _UpperCAmelCase     =     max_position_embeddings
              _UpperCAmelCase     =     type_vocab_size
              _UpperCAmelCase     =     initializer_range
              _UpperCAmelCase     =     relative_attention
              _UpperCAmelCase     =     max_relative_positions
              _UpperCAmelCase     =     pad_token_id
              _UpperCAmelCase     =     position_biased_input

              # Backwards compatibility
              if type(a__     ) == str:
                     _UpperCAmelCase     =     [x.strip() for x in pos_att_type.lower().split('|'     )]

              _UpperCAmelCase     =     pos_att_type
              _UpperCAmelCase     =     vocab_size
              _UpperCAmelCase     =     layer_norm_eps

              _UpperCAmelCase     =     kwargs.get('pooler_hidden_size'    ,  a__     )
              _UpperCAmelCase     =     pooler_dropout
              _UpperCAmelCase     =     pooler_hidden_act



class 	lowerCAmelCase					(      snake_case							):






       @property
       def 							__A (   self     ):
              if self.task == "multiple-choice":
                     _UpperCAmelCase     =     {0: 'batch', 1: 'choice', 2: 'sequence'}
              else:
                     _UpperCAmelCase     =     {0: 'batch', 1: 'sequence'}
              if self._config.type_vocab_size > 0:
                     return OrderedDict(
                         [('input_ids', dynamic_axis), ('attention_mask', dynamic_axis), ('token_type_ids', dynamic_axis)]     )
              else:
                     return OrderedDict([('input_ids', dynamic_axis), ('attention_mask', dynamic_axis)]     )






       @property
       def 							__A (   self     ):
              return 12






       def 							__A (   self    ,  a__    ,  a__ = -1    ,  a__ = -1    ,  a__ = -1    ,  a__ = False    ,  a__ = None    ,  a__ = 3    ,  a__ = 40    ,  a__ = 40    ,  a__ = None    ,  ):
              _UpperCAmelCase     =     super().generate_dummy_inputs(preprocessor=a__    ,  framework=a__     )
              if self._config.type_vocab_size == 0 and "token_type_ids" in dummy_inputs:
                     del dummy_inputs["token_type_ids"]
              return dummy_inputs






