



import warnings
from typing import List, Optional, Union

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy
from ...utils import TensorType



class   UpperCAmelCase_    (       a):
							lowerCamelCase__   			=		['image_processor', 'tokenizer']
							lowerCamelCase__   			=		'ViltImageProcessor'
							lowerCamelCase__   			=		('BertTokenizer', 'BertTokenizerFast')







							def __init__(   self,			__a=None,			__a=None,			**__a):

														'''simple docstring'''

														_lowerCAmelCase     :							int    =    None
														if "feature_extractor" in kwargs:
																					warnings.warn(
																					    "The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`"
																					    " instead.",			__a,			)
																					_lowerCAmelCase     :							int    =    kwargs.pop("feature_extractor")

														_lowerCAmelCase     :							str    =    image_processor if image_processor is not None else feature_extractor
														if image_processor is None:
																					raise ValueError("You need to specify an `image_processor`.")
														if tokenizer is None:
																					raise ValueError("You need to specify a `tokenizer`.")

														super().__init__(__a,			__a)
														_lowerCAmelCase     :							int    =    self.image_processor







							def __call__(   self,			__a,			__a = None,			__a = True,			__a = False,			__a = None,			__a = None,			__a = 0,			__a = None,			__a = None,			__a = None,			__a = False,			__a = False,			__a = False,			__a = False,			__a = True,			__a = None,			**__a,			):

														'''simple docstring'''

														_lowerCAmelCase     :							Dict    =    self.tokenizer(
														    text=__a,			add_special_tokens=__a,			padding=__a,			truncation=__a,			max_length=__a,			stride=__a,			pad_to_multiple_of=__a,			return_token_type_ids=__a,			return_attention_mask=__a,			return_overflowing_tokens=__a,			return_special_tokens_mask=__a,			return_offsets_mapping=__a,			return_length=__a,			verbose=__a,			return_tensors=__a,			**__a,			)
														# add pixel_values + pixel_mask
														_lowerCAmelCase     :							List[Any]    =    self.image_processor(__a,			return_tensors=__a)
														encoding.update(__a)

														return encoding







							def    snake_case__      (   self,			*__a,			**__a):

														'''simple docstring'''

														return self.tokenizer.batch_decode(*__a,			**__a)







							def    snake_case__      (   self,			*__a,			**__a):

														'''simple docstring'''

														return self.tokenizer.decode(*__a,			**__a)







							@property
							def    snake_case__      (   self):

														'''simple docstring'''

														_lowerCAmelCase     :							Dict    =    self.tokenizer.model_input_names
														_lowerCAmelCase     :							int    =    self.image_processor.model_input_names
														return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names))







							@property
							def    snake_case__      (   self):

														'''simple docstring'''

														warnings.warn(
														    "`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead.",			__a,			)
														return self.image_processor_class







							@property
							def    snake_case__      (   self):

														'''simple docstring'''

														warnings.warn(
														    "`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead.",			__a,			)
														return self.image_processor





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
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices


_snake_case		=  logging.get_logger(__name__)

_snake_case		=  {
    "microsoft/swin-tiny-patch4-window7-224": (
        "https://huggingface.co/microsoft/swin-tiny-patch4-window7-224/resolve/main/config.json"
    ),
    # See all Swin models at https://huggingface.co/models?filter=swin
}



class   UpperCAmelCase_    (       a   ,					a):
							lowerCamelCase__   			=		'swin'

							lowerCamelCase__   			=		{
							    'num_attention_heads': 'num_heads',
							    'num_hidden_layers': 'num_layers',
							}







							def __init__(   self,			__a=224,			__a=4,			__a=3,			__a=96,			__a=[2, 2, 6, 2],			__a=[3, 6, 12, 24],			__a=7,			__a=4.0,			__a=True,			__a=0.0,			__a=0.0,			__a=0.1,			__a="gelu",			__a=False,			__a=0.02,			__a=1E-5,			__a=32,			__a=None,			__a=None,			**__a,			):

														'''simple docstring'''

														super().__init__(**__a)

														_lowerCAmelCase     :							Any    =    image_size
														_lowerCAmelCase     :							Union[str, Any]    =    patch_size
														_lowerCAmelCase     :							Tuple    =    num_channels
														_lowerCAmelCase     :							List[Any]    =    embed_dim
														_lowerCAmelCase     :							Tuple    =    depths
														_lowerCAmelCase     :							Optional[Any]    =    len(__a)
														_lowerCAmelCase     :							int    =    num_heads
														_lowerCAmelCase     :							int    =    window_size
														_lowerCAmelCase     :							int    =    mlp_ratio
														_lowerCAmelCase     :							List[Any]    =    qkv_bias
														_lowerCAmelCase     :							str    =    hidden_dropout_prob
														_lowerCAmelCase     :							Union[str, Any]    =    attention_probs_dropout_prob
														_lowerCAmelCase     :							Any    =    drop_path_rate
														_lowerCAmelCase     :							int    =    hidden_act
														_lowerCAmelCase     :							Tuple    =    use_absolute_embeddings
														_lowerCAmelCase     :							Optional[int]    =    layer_norm_eps
														_lowerCAmelCase     :							Tuple    =    initializer_range
														_lowerCAmelCase     :							Tuple    =    encoder_stride
														# we set the hidden_size attribute in order to make Swin work with VisionEncoderDecoderModel
														# this indicates the channel dimension after the last stage of the model
														_lowerCAmelCase     :							List[str]    =    int(embed_dim * 2 ** (len(__a) - 1))
														_lowerCAmelCase     :							List[Any]    =    ["stem"] + [f"stage{idx}" for idx in range(1,			len(__a) + 1)]
														_lowerCAmelCase   ,    _lowerCAmelCase     :							Optional[int]    =    get_aligned_output_features_output_indices(
														    out_features=__a,			out_indices=__a,			stage_names=self.stage_names)



class   UpperCAmelCase_    (       a):
							lowerCamelCase__   			=		version.parse('1.11')







							@property
							def    snake_case__      (   self):

														'''simple docstring'''

														return OrderedDict(
														    [
														        ("pixel_values", {0: "batch", 1: "num_channels", 2: "height", 3: "width"}),
														    ])







							@property
							def    snake_case__      (   self):

														'''simple docstring'''

														return 1E-4
