



'''simple docstring'''





import re
import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin



class  snake_case__						(    SCREAMING_SNAKE_CASE_				):
 A__				= ['''image_processor''', '''tokenizer''']
 A__				= '''AutoImageProcessor'''
 A__				= '''AutoTokenizer'''
 def __init__(   self						:							List[str]      ,     __a						:							Optional[int]=None      ,     __a						:							Any=None      ,     **__a						:							Optional[int]  )      ->   Union[str, Any]:







       '''simple docstring'''
       __snake_case :   str													=    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      ,     )
             __snake_case :   Tuple													=    kwargs.pop('feature_extractor'  )

       __snake_case :   Union[str, Any]													=    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  )
       __snake_case :   Any													=    self.image_processor
       __snake_case :   int													=    False
 def __call__(   self						:							str      ,     *__a						:							List[str]      ,     **__a						:							List[str]  )      ->   Dict:







       '''simple docstring'''
       # For backward compatibility
       if self._in_target_context_manager:
             return self.current_processor(*__a      ,     **__a  )

       __snake_case :   List[Any]													=    kwargs.pop('images'      ,     __a  )
       __snake_case :   Any													=    kwargs.pop('text'      ,     __a  )
       if len(__a  ) > 0:
             __snake_case :   List[Any]													=    args[0]
             __snake_case :   Dict													=    args[1:]

       if images is None and text is None:
             raise ValueError('You need to specify either an `images` or `text` input to process.'  )

       if images is not None:
             __snake_case :   int													=    self.image_processor(__a      ,     *__a      ,     **__a  )
       if text is not None:
             __snake_case :   Tuple													=    self.tokenizer(__a      ,     **__a  )

       if text is None:
             return inputs
       elif images is None:
             return encodings
       else:
             __snake_case :   List[str]													=    encodings['input_ids']
             return inputs
 def A_   (   self						:							str      ,     *__a						:							Union[str, Any]      ,     **__a						:							Optional[Any]  )      ->   List[str]:







       '''simple docstring'''
       return self.tokenizer.batch_decode(*__a      ,     **__a  )
 def A_   (   self						:							Any      ,     *__a						:							List[Any]      ,     **__a						:							Dict  )      ->   List[Any]:







       '''simple docstring'''
       return self.tokenizer.decode(*__a      ,     **__a  )
 @contextmanager
 def A_   (   self						:							str  )      ->   List[Any]:







       '''simple docstring'''
       warnings.warn(
           '`as_target_processor` is deprecated and will be removed in v5 of Transformers. You can process your '
           'labels by using the argument `text` of the regular `__call__` method (either in the same call as '
           'your images inputs, or in a separate call.'  )
       __snake_case :   Union[str, Any]													=    True
       __snake_case :   List[Any]													=    self.tokenizer
       yield
       __snake_case :   str													=    self.image_processor
       __snake_case :   Tuple													=    False
 def A_   (   self						:							List[str]      ,     __a						:							Tuple      ,     __a						:							Union[str, Any]=False      ,     __a						:							str=None  )      ->   List[str]:







       '''simple docstring'''
       if added_vocab is None:
             __snake_case :   List[Any]													=    self.tokenizer.get_added_vocab()

       __snake_case :   Tuple													=    {}

       while tokens:
             __snake_case :   Optional[Any]													=    re.search(r'<s_(.*?)>'      ,     __a      ,     re.IGNORECASE  )
             if start_token is None:
                   break
             __snake_case :   Any													=    start_token.group(1  )
             __snake_case :   Dict													=    re.search(rf'''</s_{key}>'''      ,     __a      ,     re.IGNORECASE  )
             __snake_case :   List[str]													=    start_token.group()
             if end_token is None:
                   __snake_case :   List[Any]													=    tokens.replace(__a      ,     ''  )
             else:
                   __snake_case :   int													=    end_token.group()
                   __snake_case :   Optional[int]													=    re.escape(__a  )
                   __snake_case :   List[str]													=    re.escape(__a  )
                   __snake_case :   Optional[int]													=    re.search(f'''{start_token_escaped}(.*?){end_token_escaped}'''      ,     __a      ,     re.IGNORECASE  )
                   if content is not None:
                         __snake_case :   Tuple													=    content.group(1  ).strip()
                         if r"<s_" in content and r"</s_" in content:  # non-leaf node
                               __snake_case :   str													=    self.tokenajson(__a      ,     is_inner_value=__a      ,     added_vocab=__a  )
                               if value:
                                     if len(__a  ) == 1:
                                           __snake_case :   int													=    value[0]
                                     __snake_case :   Union[str, Any]													=    value
                         else:  # leaf nodes
                               __snake_case :   Any													=    []
                               for leaf in content.split(r'<sep/>'  ):
                                     __snake_case :   str													=    leaf.strip()
                                     if leaf in added_vocab and leaf[0] == "<" and leaf[-2:] == "/>":
                                           __snake_case :   Any													=    leaf[1:-2]  # for categorical special tokens
                                     output[key].append(__a  )
                               if len(output[key]  ) == 1:
                                     __snake_case :   int													=    output[key][0]

                   __snake_case :   Union[str, Any]													=    tokens[tokens.find(__a  ) + len(__a  ) :].strip()
                   if tokens[:6] == r"<sep/>":  # non-leaf nodes
                         return [output] + self.tokenajson(tokens[6:]      ,     is_inner_value=__a      ,     added_vocab=__a  )

       if len(__a  ):
             return [output] if is_inner_value else output
       else:
             return [] if is_inner_value else {"text_sequence": tokens}
 @property
 def A_   (   self						:							Optional[int]  )      ->   Any:







       '''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 A_   (   self						:							Union[str, Any]  )      ->   Optional[int]:







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








'''simple docstring'''





from ...configuration_utils import PretrainedConfig
from ...utils import logging


A__    :   Optional[Any]           =					logging.get_logger(__name__)

A__    :   List[str]           =					{
    '''microsoft/cvt-13''': '''https://huggingface.co/microsoft/cvt-13/resolve/main/config.json''',
    # See all Cvt models at https://huggingface.co/models?filter=cvt
}



class  snake_case__						(    SCREAMING_SNAKE_CASE_				):
 A__				= '''cvt'''
 def __init__(   self						:							Optional[Any]      ,     __a						:							Union[str, Any]=3      ,     __a						:							List[Any]=[7, 3, 3]      ,     __a						:							Optional[int]=[4, 2, 2]      ,     __a						:							Dict=[2, 1, 1]      ,     __a						:							Union[str, Any]=[64, 192, 384]      ,     __a						:							int=[1, 3, 6]      ,     __a						:							List[str]=[1, 2, 10]      ,     __a						:							Optional[Any]=[4.0, 4.0, 4.0]      ,     __a						:							Any=[0.0, 0.0, 0.0]      ,     __a						:							List[str]=[0.0, 0.0, 0.0]      ,     __a						:							List[Any]=[0.0, 0.0, 0.1]      ,     __a						:							List[str]=[True, True, True]      ,     __a						:							int=[False, False, True]      ,     __a						:							Dict=["dw_bn", "dw_bn", "dw_bn"]      ,     __a						:							List[str]=[3, 3, 3]      ,     __a						:							Union[str, Any]=[1, 1, 1]      ,     __a						:							Optional[int]=[2, 2, 2]      ,     __a						:							Optional[Any]=[1, 1, 1]      ,     __a						:							List[str]=[1, 1, 1]      ,     __a						:							List[str]=0.0_2      ,     __a						:							List[str]=1e-12      ,     **__a						:							List[str]      ,     )      ->   Dict:







       '''simple docstring'''
       super().__init__(**__a  )
       __snake_case :   int													=    num_channels
       __snake_case :   Union[str, Any]													=    patch_sizes
       __snake_case :   Any													=    patch_stride
       __snake_case :   List[str]													=    patch_padding
       __snake_case :   Optional[Any]													=    embed_dim
       __snake_case :   Union[str, Any]													=    num_heads
       __snake_case :   Dict													=    depth
       __snake_case :   Optional[Any]													=    mlp_ratio
       __snake_case :   List[str]													=    attention_drop_rate
       __snake_case :   Optional[int]													=    drop_rate
       __snake_case :   Optional[int]													=    drop_path_rate
       __snake_case :   Any													=    qkv_bias
       __snake_case :   int													=    cls_token
       __snake_case :   Optional[int]													=    qkv_projection_method
       __snake_case :   List[Any]													=    kernel_qkv
       __snake_case :   List[Any]													=    padding_kv
       __snake_case :   int													=    stride_kv
       __snake_case :   List[str]													=    padding_q
       __snake_case :   Dict													=    stride_q
       __snake_case :   Tuple													=    initializer_range
       __snake_case :   List[Any]													=    layer_norm_eps



