

import re
import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin



class    _a						(a__    ):


					'''simple docstring'''






					UpperCAmelCase__:       List[str]  							=	['''image_processor''', '''tokenizer''']
					UpperCAmelCase__:       Optional[Any]  							=	'''AutoImageProcessor'''
					UpperCAmelCase__:       Any  							=	'''AutoTokenizer'''






					def __init__(			self   ,	A__=None   ,	A__=None   ,	**A__      ):
						A__							:   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__   ,	)
							A__							:   Optional[Any]					       =		kwargs.pop("""feature_extractor"""      )

						A__							:   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__      )
						A__							:   str					       =		self.image_processor
						A__							:   List[str]					       =		False






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

						A__							:   Optional[int]					       =		kwargs.pop("""images"""   ,	A__      )
						A__							:   Dict					       =		kwargs.pop("""text"""   ,	A__      )
						if len(A__      ) > 0:
							A__							:   Optional[int]					       =		args[0]
							A__							:   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__							:   Any					       =		self.image_processor(A__   ,	*A__   ,	**A__      )
						if text is not None:
							A__							:   List[str]					       =		self.tokenizer(A__   ,	**A__      )

						if text is None:
							return inputs
						elif images is None:
							return encodings
						else:
							A__							:   List[str]					       =		encodings["input_ids"]
							return inputs






					def   __A      (			self   ,	*A__   ,	**A__      ):
						return self.tokenizer.batch_decode(*A__   ,	**A__      )






					def   __A      (			self   ,	*A__   ,	**A__      ):
						return self.tokenizer.decode(*A__   ,	**A__      )






					@contextmanager
					def   __A      (			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__							:   int					       =		True
						A__							:   List[Any]					       =		self.tokenizer
						yield
						A__							:   Tuple					       =		self.image_processor
						A__							:   List[Any]					       =		False






					def   __A      (			self   ,	A__   ,	A__=False   ,	A__=None      ):
						if added_vocab is None:
							A__							:   str					       =		self.tokenizer.get_added_vocab()

						A__							:   Dict					       =		{}

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

								A__							:   str					       =		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      ):
						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      ):
						warnings.warn(
						    """`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead."""   ,	A__   ,	)
						return self.image_processor






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


A_	:			str  	=      logging.get_logger(__name__)

A_	:			Any  	=      {
    '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    _a						(__magic_name__    ):


					'''simple docstring'''






					UpperCAmelCase__:       Dict  							=	'''falcon'''
					UpperCAmelCase__:       Any  							=	['''past_key_values''']






					def __init__(			self   ,	A__=6_5024   ,	A__=4544   ,	A__=32   ,	A__=71   ,	A__=1e-5   ,	A__=0.0_2   ,	A__=True   ,	A__=0.0   ,	A__=0.0   ,	A__=None   ,	A__=False   ,	A__=False   ,	A__=True   ,	A__=True   ,	A__=False   ,	A__=11   ,	A__=11   ,	**A__   ,	):
						A__							:   Dict					       =		vocab_size
						# Backward compatibility with n_embed kwarg
						A__							:   Union[str, Any]					       =		kwargs.pop("""n_embed"""   ,	A__      )
						A__							:   Optional[Any]					       =		hidden_size if n_embed is None else n_embed
						A__							:   Any					       =		num_hidden_layers
						A__							:   Any					       =		num_attention_heads
						A__							:   Optional[Any]					       =		layer_norm_epsilon
						A__							:   Tuple					       =		initializer_range
						A__							:   Tuple					       =		use_cache
						A__							:   str					       =		hidden_dropout
						A__							:   List[str]					       =		attention_dropout

						A__							:   List[Any]					       =		bos_token_id
						A__							:   Optional[Any]					       =		eos_token_id
						A__							:   Optional[Any]					       =		num_attention_heads if num_kv_heads is None else num_kv_heads
						A__							:   List[str]					       =		alibi
						A__							:   Tuple					       =		new_decoder_architecture
						A__							:   List[str]					       =		multi_query  # Ignored when new_decoder_architecture is True
						A__							:   List[Any]					       =		parallel_attn
						A__							:   int					       =		bias

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






					@property
					def   __A      (			self      ):
						return self.hidden_size // self.num_attention_heads






					@property
					def   __A      (			self      ):
						return not self.alibi



