
"""simple docstring"""

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				(		SCREAMING_SNAKE_CASE_				):
      __SCREAMING_SNAKE_CASE :				List[str]				   =						["image_processor", "tokenizer"]
      __SCREAMING_SNAKE_CASE :				Union[str, Any]				   =						"ViltImageProcessor"
      __SCREAMING_SNAKE_CASE :				List[str]				   =						("BertTokenizer", "BertTokenizerFast")




      def __init__(				self ,							lowercase_=None ,							lowercase_=None ,							**lowercase_				)    ->       Any:
          UpperCAmelCase          =       None
          if "feature_extractor" in kwargs:
              warnings.warn(
                  'The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`'
                  ' instead.' ,							lowercase_ ,							)
              UpperCAmelCase          =       kwargs.pop('feature_extractor'				)

          UpperCAmelCase          =       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__(lowercase_ ,							lowercase_				)
          UpperCAmelCase          =       self.image_processor




      def __call__(				self ,							lowercase_ ,							lowercase_ = None ,							lowercase_ = True ,							lowercase_ = False ,							lowercase_ = None ,							lowercase_ = None ,							lowercase_ = 0 ,							lowercase_ = None ,							lowercase_ = None ,							lowercase_ = None ,							lowercase_ = False ,							lowercase_ = False ,							lowercase_ = False ,							lowercase_ = False ,							lowercase_ = True ,							lowercase_ = None ,							**lowercase_ ,							)    ->       BatchEncoding:
          UpperCAmelCase          =       self.tokenizer(
              text=lowercase_ ,							add_special_tokens=lowercase_ ,							padding=lowercase_ ,							truncation=lowercase_ ,							max_length=lowercase_ ,							stride=lowercase_ ,							pad_to_multiple_of=lowercase_ ,							return_token_type_ids=lowercase_ ,							return_attention_mask=lowercase_ ,							return_overflowing_tokens=lowercase_ ,							return_special_tokens_mask=lowercase_ ,							return_offsets_mapping=lowercase_ ,							return_length=lowercase_ ,							verbose=lowercase_ ,							return_tensors=lowercase_ ,							**lowercase_ ,							)
          # add pixel_values + pixel_mask
          UpperCAmelCase          =       self.image_processor(lowercase_ ,							return_tensors=lowercase_				)
          encoding.update(lowercase_				)

          return encoding




      def      a_   (				self ,							*lowercase_ ,							**lowercase_				)    ->       List[Any]:
          return self.tokenizer.batch_decode(*lowercase_ ,							**lowercase_				)




      def      a_   (				self ,							*lowercase_ ,							**lowercase_				)    ->       Dict:
          return self.tokenizer.decode(*lowercase_ ,							**lowercase_				)




      @property
      def      a_   (				self				)    ->       str:
          UpperCAmelCase          =       self.tokenizer.model_input_names
          UpperCAmelCase          =       self.image_processor.model_input_names
          return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names				)				)




      @property
      def      a_   (				self				)    ->       Union[str, Any]:
          warnings.warn(
              '`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead.' ,							lowercase_ ,							)
          return self.image_processor_class




      @property
      def      a_   (				self				)    ->       List[str]:
          warnings.warn(
              '`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead.' ,							lowercase_ ,							)
          return self.image_processor





"""simple docstring"""

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


SCREAMING_SNAKE_CASE_            =    logging.get_logger(__name__)

SCREAMING_SNAKE_CASE_            =    {
    '''tiiuae/falcon-40b''': '''https://huggingface.co/tiiuae/falcon-40b/resolve/main/config.json''',
    '''tiiuae/falcon-7b''': '''https://huggingface.co/tiiuae/falcon-7b/resolve/main/config.json''',
}
class   _UpperCAmelCase				(		SCREAMING_SNAKE_CASE_				):
      __SCREAMING_SNAKE_CASE :				Optional[Any]				   =						"falcon"
      __SCREAMING_SNAKE_CASE :				List[Any]				   =						["past_key_values"]




      def __init__(				self ,							lowercase_=6_5_0_2_4 ,							lowercase_=4_5_4_4 ,							lowercase_=3_2 ,							lowercase_=7_1 ,							lowercase_=1E-5 ,							lowercase_=0.0_2 ,							lowercase_=True ,							lowercase_=0.0 ,							lowercase_=0.0 ,							lowercase_=None ,							lowercase_=False ,							lowercase_=False ,							lowercase_=True ,							lowercase_=True ,							lowercase_=False ,							lowercase_=1_1 ,							lowercase_=1_1 ,							**lowercase_ ,							)    ->       Any:
          UpperCAmelCase          =       vocab_size
          # Backward compatibility with n_embed kwarg
          UpperCAmelCase          =       kwargs.pop('n_embed' ,							lowercase_				)
          UpperCAmelCase          =       hidden_size if n_embed is None else n_embed
          UpperCAmelCase          =       num_hidden_layers
          UpperCAmelCase          =       num_attention_heads
          UpperCAmelCase          =       layer_norm_epsilon
          UpperCAmelCase          =       initializer_range
          UpperCAmelCase          =       use_cache
          UpperCAmelCase          =       hidden_dropout
          UpperCAmelCase          =       attention_dropout

          UpperCAmelCase          =       bos_token_id
          UpperCAmelCase          =       eos_token_id
          UpperCAmelCase          =       num_attention_heads if num_kv_heads is None else num_kv_heads
          UpperCAmelCase          =       alibi
          UpperCAmelCase          =       new_decoder_architecture
          UpperCAmelCase          =       multi_query  # Ignored when new_decoder_architecture is True
          UpperCAmelCase          =       parallel_attn
          UpperCAmelCase          =       bias

          super().__init__(bos_token_id=lowercase_ ,							eos_token_id=lowercase_ ,							**lowercase_				)




      @property
      def      a_   (				self				)    ->       List[Any]:
          return self.hidden_size // self.num_attention_heads




      @property
      def      a_   (				self				)    ->       List[str]:
          return not self.alibi



