


import re
import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin







class 		_snake_case  (				_snake_case							):
 SCREAMING_SNAKE_CASE__				=	['image_processor', 'tokenizer']
 SCREAMING_SNAKE_CASE__				=	'AutoImageProcessor'
 SCREAMING_SNAKE_CASE__				=	'AutoTokenizer'




 def __init__(		self ,  _lowerCamelCase=None ,  _lowerCamelCase=None ,  **_lowerCamelCase   ):
       a						: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.''' ,  _lowerCamelCase ,  )
             a						:str										=	kwargs.pop('''feature_extractor'''   )

       a						:Tuple										=	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__(_lowerCamelCase ,  _lowerCamelCase   )
       a						:List[str]										=	self.image_processor
       a						:Any										=	False




 def __call__(		self ,  *_lowerCamelCase ,  **_lowerCamelCase   ):
       # For backward compatibility
       if self._in_target_context_manager:
             return self.current_processor(*_lowerCamelCase ,  **_lowerCamelCase   )

       a						:Any										=	kwargs.pop('''images''' ,  _lowerCamelCase   )
       a						:Optional[Any]										=	kwargs.pop('''text''' ,  _lowerCamelCase   )
       if len(_lowerCamelCase   ) > 0:
             a						:Tuple										=	args[0]
             a						:Optional[Any]										=	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:
             a						:List[Any]										=	self.image_processor(_lowerCamelCase ,  *_lowerCamelCase ,  **_lowerCamelCase   )
       if text is not None:
             a						:Tuple										=	self.tokenizer(_lowerCamelCase ,  **_lowerCamelCase   )

       if text is None:
             return inputs
       elif images is None:
             return encodings
       else:
             a						:Optional[int]										=	encodings['''input_ids''']
             return inputs




 def 	SCREAMING_SNAKE_CASE__    (		self ,  *_lowerCamelCase ,  **_lowerCamelCase   ):
       return self.tokenizer.batch_decode(*_lowerCamelCase ,  **_lowerCamelCase   )




 def 	SCREAMING_SNAKE_CASE__    (		self ,  *_lowerCamelCase ,  **_lowerCamelCase   ):
       return self.tokenizer.decode(*_lowerCamelCase ,  **_lowerCamelCase   )




 @contextmanager
 def 	SCREAMING_SNAKE_CASE__    (		self   ):
       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.'''   )
       a						:Dict										=	True
       a						:Dict										=	self.tokenizer
       yield
       a						:List[Any]										=	self.image_processor
       a						:List[str]										=	False




 def 	SCREAMING_SNAKE_CASE__    (		self ,  _lowerCamelCase ,  _lowerCamelCase=False ,  _lowerCamelCase=None   ):
       if added_vocab is None:
             a						:List[str]										=	self.tokenizer.get_added_vocab()

       a						:str										=	{}

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

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

       if len(_lowerCamelCase   ):
             return [output] if is_inner_value else output
       else:
             return [] if is_inner_value else {"text_sequence": tokens}




 @property
 def 	SCREAMING_SNAKE_CASE__    (		self   ):
       warnings.warn(
           '''`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead.''' ,  _lowerCamelCase ,  )
       return self.image_processor_class




 @property
 def 	SCREAMING_SNAKE_CASE__    (		self   ):
       warnings.warn(
           '''`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead.''' ,  _lowerCamelCase ,  )
       return self.image_processor









from collections import OrderedDict
from typing import List, Mapping

from packaging import version

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


snake_case    :   Union[str, Any]	    =					logging.get_logger(__name__)

snake_case    :   List[str]	    =					{
    '''google/efficientnet-b7''': '''https://huggingface.co/google/efficientnet-b7/resolve/main/config.json''',
}







class 		_snake_case  (				_snake_case							):
 SCREAMING_SNAKE_CASE__				=	'efficientnet'




 def __init__(		self ,  _lowerCamelCase = 3 ,  _lowerCamelCase = 600 ,  _lowerCamelCase = 2.0 ,  _lowerCamelCase = 3.1 ,  _lowerCamelCase = 8 ,  _lowerCamelCase = [3, 3, 5, 3, 5, 5, 3] ,  _lowerCamelCase = [32, 16, 24, 40, 80, 112, 192] ,  _lowerCamelCase = [16, 24, 40, 80, 112, 192, 320] ,  _lowerCamelCase = [] ,  _lowerCamelCase = [1, 2, 2, 2, 1, 2, 1] ,  _lowerCamelCase = [1, 2, 2, 3, 3, 4, 1] ,  _lowerCamelCase = [1, 6, 6, 6, 6, 6, 6] ,  _lowerCamelCase = 0.25 ,  _lowerCamelCase = "swish" ,  _lowerCamelCase = 2560 ,  _lowerCamelCase = "mean" ,  _lowerCamelCase = 0.02 ,  _lowerCamelCase = 0.001 ,  _lowerCamelCase = 0.99 ,  _lowerCamelCase = 0.5 ,  _lowerCamelCase = 0.2 ,  **_lowerCamelCase ,  ):
       super().__init__(**_lowerCamelCase   )

       a						:Optional[int]										=	num_channels
       a						:List[str]										=	image_size
       a						:int										=	width_coefficient
       a						:Optional[Any]										=	depth_coefficient
       a						:Any										=	depth_divisor
       a						:Any										=	kernel_sizes
       a						:Tuple										=	in_channels
       a						:Union[str, Any]										=	out_channels
       a						:Any										=	depthwise_padding
       a						:Any										=	strides
       a						:Optional[Any]										=	num_block_repeats
       a						:Tuple										=	expand_ratios
       a						:Dict										=	squeeze_expansion_ratio
       a						:int										=	hidden_act
       a						:Dict										=	hidden_dim
       a						:Tuple										=	pooling_type
       a						:Any										=	initializer_range
       a						:Tuple										=	batch_norm_eps
       a						:Optional[int]										=	batch_norm_momentum
       a						:List[Any]										=	dropout_rate
       a						:Optional[int]										=	drop_connect_rate
       a						:Tuple										=	sum(_lowerCamelCase   ) * 4







class 		_snake_case  (				_snake_case							):
 SCREAMING_SNAKE_CASE__				=	version.parse('1.11'							)




 @property
 def 	SCREAMING_SNAKE_CASE__    (		self   ):
       return OrderedDict(
           [
               ('''pixel_values''', {0: '''batch''', 1: '''num_channels''', 2: '''height''', 3: '''width'''}),
           ]   )




 @property
 def 	SCREAMING_SNAKE_CASE__    (		self   ):
       return 1e-5





