





"""simple docstring"""




import unittest

import numpy as np

from transformers.testing_utils import require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
						import torch

if is_vision_available():
						from PIL import Image

						from transformers import DeiTImageProcessor




class  _a						(      unittest.TestCase				):






				def __init__( self		:    Tuple, lowerCAmelCase__		:    Union[str, Any], lowerCAmelCase__		:    Optional[Any]=7, lowerCAmelCase__		:    Optional[Any]=3, lowerCAmelCase__		:    List[str]=1_8, lowerCAmelCase__		:    Optional[Any]=3_0, lowerCAmelCase__		:    List[Any]=4_0_0, lowerCAmelCase__		:    Optional[int]=True, lowerCAmelCase__		:    Union[str, Any]=None, lowerCAmelCase__		:    Any=True, lowerCAmelCase__		:    str=None, lowerCAmelCase__		:    List[Any]=True, lowerCAmelCase__		:    str=[0.5, 0.5, 0.5], lowerCAmelCase__		:    Union[str, Any]=[0.5, 0.5, 0.5], )	->      List[str]:




										'''simple docstring'''



										_UpperCamelCase			:					str     =    size if size is not None else {'''height''': 2_0, '''width''': 2_0}
										_UpperCamelCase			:					Any     =    crop_size if crop_size is not None else {'''height''': 1_8, '''width''': 1_8}

										_UpperCamelCase			:					Dict     =    parent
										_UpperCamelCase			:					Optional[Any]     =    batch_size
										_UpperCamelCase			:					Tuple     =    num_channels
										_UpperCamelCase			:					str     =    image_size
										_UpperCamelCase			:					int     =    min_resolution
										_UpperCamelCase			:					int     =    max_resolution
										_UpperCamelCase			:					Optional[int]     =    do_resize
										_UpperCamelCase			:					Optional[Any]     =    size
										_UpperCamelCase			:					Union[str, Any]     =    do_center_crop
										_UpperCamelCase			:					List[str]     =    crop_size
										_UpperCamelCase			:					Optional[int]     =    do_normalize
										_UpperCamelCase			:					Tuple     =    image_mean
										_UpperCamelCase			:					Any     =    image_std






				def 				snake_case	( self		:    Union[str, Any]							)	->      List[Any]:




										'''simple docstring'''



										return {
										    "do_resize": self.do_resize,
										    "size": self.size,
										    "do_center_crop": self.do_center_crop,
										    "crop_size": self.crop_size,
										    "do_normalize": self.do_normalize,
										    "image_mean": self.image_mean,
										    "image_std": self.image_std,
										}




@require_torch
@require_vision
class  _a						(      _lowerCAmelCase	,				unittest.TestCase				):
				UpperCamelCase								=    DeiTImageProcessor if is_vision_available() else None
				UpperCamelCase								=    True






				def 				snake_case	( self		:    Dict							)	->      Tuple:




										'''simple docstring'''



										_UpperCamelCase			:					Any     =    DeiTImageProcessingTester(self							)






				@property
				def 				snake_case	( self		:    List[str]							)	->      List[str]:




										'''simple docstring'''



										return self.image_processor_tester.prepare_image_processor_dict()






				def 				snake_case	( self		:    Any							)	->      Union[str, Any]:




										'''simple docstring'''



										_UpperCamelCase			:					Tuple     =    self.image_processing_class(**self.image_processor_dict							)
										self.assertTrue(hasattr(lowerCAmelCase__, '''do_resize'''							)							)
										self.assertTrue(hasattr(lowerCAmelCase__, '''size'''							)							)
										self.assertTrue(hasattr(lowerCAmelCase__, '''do_center_crop'''							)							)
										self.assertTrue(hasattr(lowerCAmelCase__, '''center_crop'''							)							)
										self.assertTrue(hasattr(lowerCAmelCase__, '''do_normalize'''							)							)
										self.assertTrue(hasattr(lowerCAmelCase__, '''image_mean'''							)							)
										self.assertTrue(hasattr(lowerCAmelCase__, '''image_std'''							)							)






				def 				snake_case	( self		:    Dict							)	->      List[Any]:




										'''simple docstring'''



										_UpperCamelCase			:					Any     =    self.image_processing_class.from_dict(self.image_processor_dict							)
										self.assertEqual(image_processor.size, {'''height''': 2_0, '''width''': 2_0}							)
										self.assertEqual(image_processor.crop_size, {'''height''': 1_8, '''width''': 1_8}							)

										_UpperCamelCase			:					Dict     =    self.image_processing_class.from_dict(self.image_processor_dict, size=4_2, crop_size=8_4							)
										self.assertEqual(image_processor.size, {'''height''': 4_2, '''width''': 4_2}							)
										self.assertEqual(image_processor.crop_size, {'''height''': 8_4, '''width''': 8_4}							)






				def 				snake_case	( self		:    int							)	->      Tuple:




										'''simple docstring'''



										pass






				def 				snake_case	( self		:    List[str]							)	->      Dict:




										'''simple docstring'''



										_UpperCamelCase			:					List[Any]     =    self.image_processing_class(**self.image_processor_dict							)
										# create random PIL images
										_UpperCamelCase			:					Optional[int]     =    prepare_image_inputs(self.image_processor_tester, equal_resolution=lowerCAmelCase__							)
										for image in image_inputs:
																self.assertIsInstance(lowerCAmelCase__, Image.Image							)

										# Test not batched input
										_UpperCamelCase			:					Optional[int]     =    image_processing(image_inputs[0], return_tensors='''pt'''							).pixel_values
										self.assertEqual(
										    encoded_images.shape, (
										        1,
										        self.image_processor_tester.num_channels,
										        self.image_processor_tester.crop_size['''height'''],
										        self.image_processor_tester.crop_size['''width'''],
										    ), )

										# Test batched
										_UpperCamelCase			:					List[str]     =    image_processing(lowerCAmelCase__, return_tensors='''pt'''							).pixel_values
										self.assertEqual(
										    encoded_images.shape, (
										        self.image_processor_tester.batch_size,
										        self.image_processor_tester.num_channels,
										        self.image_processor_tester.crop_size['''height'''],
										        self.image_processor_tester.crop_size['''width'''],
										    ), )






				def 				snake_case	( self		:    List[Any]							)	->      Tuple:




										'''simple docstring'''



										_UpperCamelCase			:					int     =    self.image_processing_class(**self.image_processor_dict							)
										# create random numpy tensors
										_UpperCamelCase			:					Tuple     =    prepare_image_inputs(self.image_processor_tester, equal_resolution=lowerCAmelCase__, numpify=lowerCAmelCase__							)
										for image in image_inputs:
																self.assertIsInstance(lowerCAmelCase__, np.ndarray							)

										# Test not batched input
										_UpperCamelCase			:					Dict     =    image_processing(image_inputs[0], return_tensors='''pt'''							).pixel_values
										self.assertEqual(
										    encoded_images.shape, (
										        1,
										        self.image_processor_tester.num_channels,
										        self.image_processor_tester.crop_size['''height'''],
										        self.image_processor_tester.crop_size['''width'''],
										    ), )

										# Test batched
										_UpperCamelCase			:					Optional[Any]     =    image_processing(lowerCAmelCase__, return_tensors='''pt'''							).pixel_values
										self.assertEqual(
										    encoded_images.shape, (
										        self.image_processor_tester.batch_size,
										        self.image_processor_tester.num_channels,
										        self.image_processor_tester.crop_size['''height'''],
										        self.image_processor_tester.crop_size['''width'''],
										    ), )






				def 				snake_case	( self		:    Optional[Any]							)	->      Tuple:




										'''simple docstring'''



										_UpperCamelCase			:					Optional[int]     =    self.image_processing_class(**self.image_processor_dict							)
										# create random PyTorch tensors
										_UpperCamelCase			:					Union[str, Any]     =    prepare_image_inputs(self.image_processor_tester, equal_resolution=lowerCAmelCase__, torchify=lowerCAmelCase__							)
										for image in image_inputs:
																self.assertIsInstance(lowerCAmelCase__, torch.Tensor							)

										# Test not batched input
										_UpperCamelCase			:					Any     =    image_processing(image_inputs[0], return_tensors='''pt'''							).pixel_values
										self.assertEqual(
										    encoded_images.shape, (
										        1,
										        self.image_processor_tester.num_channels,
										        self.image_processor_tester.crop_size['''height'''],
										        self.image_processor_tester.crop_size['''width'''],
										    ), )

										# Test batched
										_UpperCamelCase			:					int     =    image_processing(lowerCAmelCase__, return_tensors='''pt'''							).pixel_values
										self.assertEqual(
										    encoded_images.shape, (
										        self.image_processor_tester.batch_size,
										        self.image_processor_tester.num_channels,
										        self.image_processor_tester.crop_size['''height'''],
										        self.image_processor_tester.crop_size['''width'''],
										    ), )









from collections import OrderedDict
from typing import Mapping

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


_lowerCamelCase					:     Optional[int]					  =  logging.get_logger(__name__)

_lowerCamelCase					:     Optional[int]					  =  {
    "squeezebert/squeezebert-uncased": (
        "https://huggingface.co/squeezebert/squeezebert-uncased/resolve/main/config.json"
    ),
    "squeezebert/squeezebert-mnli": "https://huggingface.co/squeezebert/squeezebert-mnli/resolve/main/config.json",
    "squeezebert/squeezebert-mnli-headless": (
        "https://huggingface.co/squeezebert/squeezebert-mnli-headless/resolve/main/config.json"
    ),
}
class 				__snake_case     (_a						):
				lowerCAmelCase__			=   SQUEEZEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP
				lowerCAmelCase__			=   "squeezebert"



				def __init__(					self					:						Optional[int]						,		_UpperCAmelCase					:						Tuple=3_0522						,		_UpperCAmelCase					:						str=768						,		_UpperCAmelCase					:						int=12						,		_UpperCAmelCase					:						Tuple=12						,		_UpperCAmelCase					:						Tuple=3072						,		_UpperCAmelCase					:						Union[str, Any]="gelu"						,		_UpperCAmelCase					:						Union[str, Any]=0.1						,		_UpperCAmelCase					:						List[Any]=0.1						,		_UpperCAmelCase					:						List[Any]=512						,		_UpperCAmelCase					:						Tuple=2						,		_UpperCAmelCase					:						Optional[Any]=0.02						,		_UpperCAmelCase					:						Any=1E-12						,		_UpperCAmelCase					:						Optional[Any]=0						,		_UpperCAmelCase					:						Union[str, Any]=768						,		_UpperCAmelCase					:						Any=4						,		_UpperCAmelCase					:						Any=4						,		_UpperCAmelCase					:						Optional[int]=4						,		_UpperCAmelCase					:						str=1						,		_UpperCAmelCase					:						Union[str, Any]=4						,		_UpperCAmelCase					:						List[str]=4						,		**_UpperCAmelCase					:						int						,		)     ->			Any:





								'''simple docstring'''




								super().__init__(pad_token_id=_UpperCAmelCase						,		**_UpperCAmelCase					)

								_lowerCAmelCase			:			Optional[Any]        =					vocab_size
								_lowerCAmelCase			:			Optional[Any]        =					hidden_size
								_lowerCAmelCase			:			Tuple        =					num_hidden_layers
								_lowerCAmelCase			:			int        =					num_attention_heads
								_lowerCAmelCase			:			List[Any]        =					hidden_act
								_lowerCAmelCase			:			List[Any]        =					intermediate_size
								_lowerCAmelCase			:			List[str]        =					hidden_dropout_prob
								_lowerCAmelCase			:			Any        =					attention_probs_dropout_prob
								_lowerCAmelCase			:			str        =					max_position_embeddings
								_lowerCAmelCase			:			int        =					type_vocab_size
								_lowerCAmelCase			:			str        =					initializer_range
								_lowerCAmelCase			:			int        =					layer_norm_eps
								_lowerCAmelCase			:			int        =					embedding_size
								_lowerCAmelCase			:			Optional[int]        =					q_groups
								_lowerCAmelCase			:			List[Any]        =					k_groups
								_lowerCAmelCase			:			List[Any]        =					v_groups
								_lowerCAmelCase			:			Dict        =					post_attention_groups
								_lowerCAmelCase			:			Optional[Any]        =					intermediate_groups
								_lowerCAmelCase			:			str        =					output_groups






class 				__snake_case     (_a						):



				@property
				def 					SCREAMING_SNAKE_CASE				(					self					:						Union[str, Any]					)     ->			Mapping[str, Mapping[int, str]]:





								'''simple docstring'''




								if self.task == "multiple-choice":
												_lowerCAmelCase			:			Optional[int]        =					{0: """batch""", 1: """choice""", 2: """sequence"""}
								else:
												_lowerCAmelCase			:			int        =					{0: """batch""", 1: """sequence"""}
								return OrderedDict(
								    [
								        ("""input_ids""", dynamic_axis),
								        ("""attention_mask""", dynamic_axis),
								        ("""token_type_ids""", dynamic_axis),
								    ]					)

