






'''simple docstring'''







import json
import os
from functools import lru_cache
from typing import Dict, List, Optional, Tuple, Union

import regex as re

from ...tokenization_utils import AddedToken, PreTrainedTokenizer
from ...tokenization_utils_base import BatchEncoding, EncodedInput
from ...utils import PaddingStrategy, logging


__lowerCAmelCase									=   logging.get_logger(__name__)


__lowerCAmelCase									=   {'vocab_file': 'vocab.json', 'merges_file': 'merges.txt'}

# See all LED models at https://huggingface.co/models?filter=LED
__lowerCAmelCase									=   {
    'vocab_file': {
        'allenai/led-base-16384': 'https://huggingface.co/allenai/led-base-16384/resolve/main/vocab.json',
    },
    'merges_file': {
        'allenai/led-base-16384': 'https://huggingface.co/allenai/led-base-16384/resolve/main/merges.txt',
    },
    'tokenizer_file': {
        'allenai/led-base-16384': 'https://huggingface.co/allenai/led-base-16384/resolve/main/tokenizer.json',
    },
}

__lowerCAmelCase									=   {
    'allenai/led-base-16384': 16_384,
}





@lru_cache()
# Copied from transformers.models.bart.tokenization_bart.bytes_to_unicode
def 		_UpperCAmelCase (				):
				a_		:	Tuple									=   (
				    list(range(ord('''!'''   )    ,		ord('''~'''   ) + 1   )   ) + list(range(ord('''¡'''   )    ,		ord('''¬'''   ) + 1   )   ) + list(range(ord('''®'''   )    ,		ord('''ÿ'''   ) + 1   )   )
				)
				a_		:	str									=   bs[:]
				a_		:	Tuple									=   0
				for b in range(2**8   ):
								if b not in bs:
												bs.append(__A   )
												cs.append(2**8 + n   )
												n += 1
				a_		:	Optional[int]									=   [chr(__A   ) for n in cs]
				return dict(zip(__A    ,		__A   )   )





def 		_UpperCAmelCase (				__A				: str   ):
				a_		:	Optional[int]									=   set()
				a_		:	Tuple									=   word[0]
				for char in word[1:]:
								pairs.add((prev_char, char)   )
								a_		:	Any									=   char
				return pairs





class 						SCREAMING_SNAKE_CASE       (       SCREAMING_SNAKE_CASE_							):
			snake_case__	=					VOCAB_FILES_NAMES
			snake_case__	=					PRETRAINED_VOCAB_FILES_MAP
			snake_case__	=					PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
			snake_case__	=					["input_ids", "attention_mask"]






			def __init__(			self   :      Optional[int]	,    __SCREAMING_SNAKE_CASE   :      Dict	,    __SCREAMING_SNAKE_CASE   :      Optional[int]	,    __SCREAMING_SNAKE_CASE   :      Optional[Any]="replace"	,    __SCREAMING_SNAKE_CASE   :      Union[str, Any]="<s>"	,    __SCREAMING_SNAKE_CASE   :      Union[str, Any]="</s>"	,    __SCREAMING_SNAKE_CASE   :      List[str]="</s>"	,    __SCREAMING_SNAKE_CASE   :      str="<s>"	,    __SCREAMING_SNAKE_CASE   :      int="<unk>"	,    __SCREAMING_SNAKE_CASE   :      str="<pad>"	,    __SCREAMING_SNAKE_CASE   :      Tuple="<mask>"	,    __SCREAMING_SNAKE_CASE   :      str=False	,    **__SCREAMING_SNAKE_CASE   :      int	,    )      ->      Optional[Any]:
							a_		:	Union[str, Any]									=   AddedToken(__SCREAMING_SNAKE_CASE	,    lstrip=__SCREAMING_SNAKE_CASE	,    rstrip=__SCREAMING_SNAKE_CASE       ) if isinstance(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE       ) else bos_token
							a_		:	str									=   AddedToken(__SCREAMING_SNAKE_CASE	,    lstrip=__SCREAMING_SNAKE_CASE	,    rstrip=__SCREAMING_SNAKE_CASE       ) if isinstance(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE       ) else eos_token
							a_		:	int									=   AddedToken(__SCREAMING_SNAKE_CASE	,    lstrip=__SCREAMING_SNAKE_CASE	,    rstrip=__SCREAMING_SNAKE_CASE       ) if isinstance(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE       ) else sep_token
							a_		:	List[str]									=   AddedToken(__SCREAMING_SNAKE_CASE	,    lstrip=__SCREAMING_SNAKE_CASE	,    rstrip=__SCREAMING_SNAKE_CASE       ) if isinstance(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE       ) else cls_token
							a_		:	int									=   AddedToken(__SCREAMING_SNAKE_CASE	,    lstrip=__SCREAMING_SNAKE_CASE	,    rstrip=__SCREAMING_SNAKE_CASE       ) if isinstance(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE       ) else unk_token
							a_		:	int									=   AddedToken(__SCREAMING_SNAKE_CASE	,    lstrip=__SCREAMING_SNAKE_CASE	,    rstrip=__SCREAMING_SNAKE_CASE       ) if isinstance(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE       ) else pad_token

							# Mask token behave like a normal word, i.e. include the space before it
							a_		:	Any									=   AddedToken(__SCREAMING_SNAKE_CASE	,    lstrip=__SCREAMING_SNAKE_CASE	,    rstrip=__SCREAMING_SNAKE_CASE       ) if isinstance(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE       ) else mask_token

							super().__init__(
							    errors=__SCREAMING_SNAKE_CASE	,    bos_token=__SCREAMING_SNAKE_CASE	,    eos_token=__SCREAMING_SNAKE_CASE	,    unk_token=__SCREAMING_SNAKE_CASE	,    sep_token=__SCREAMING_SNAKE_CASE	,    cls_token=__SCREAMING_SNAKE_CASE	,    pad_token=__SCREAMING_SNAKE_CASE	,    mask_token=__SCREAMING_SNAKE_CASE	,    add_prefix_space=__SCREAMING_SNAKE_CASE	,    **__SCREAMING_SNAKE_CASE	,    )

							with open(__SCREAMING_SNAKE_CASE	,    encoding='''utf-8'''       ) as vocab_handle:
											a_		:	Dict									=   json.load(__SCREAMING_SNAKE_CASE       )
							a_		:	Any									=   {v: k for k, v in self.encoder.items()}
							a_		:	List[Any]									=   errors  # how to handle errors in decoding
							a_		:	int									=   bytes_to_unicode()
							a_		:	Dict									=   {v: k for k, v in self.byte_encoder.items()}
							with open(__SCREAMING_SNAKE_CASE	,    encoding='''utf-8'''       ) as merges_handle:
											a_		:	Union[str, Any]									=   merges_handle.read().split('''\n'''       )[1:-1]
							a_		:	List[str]									=   [tuple(merge.split()       ) for merge in bpe_merges]
							a_		:	Optional[Any]									=   dict(zip(__SCREAMING_SNAKE_CASE	,    range(len(__SCREAMING_SNAKE_CASE       )       )       )       )
							a_		:	List[Any]									=   {}
							a_		:	Optional[int]									=   add_prefix_space

							# Should have added re.IGNORECASE so BPE merges can happen for capitalized versions of contractions
							a_		:	Optional[int]									=   re.compile(r'''\'s|\'t|\'re|\'ve|\'m|\'ll|\'d| ?\p{L}+| ?\p{N}+| ?[^\s\p{L}\p{N}]+|\s+(?!\S)|\s+'''       )






			@property
			# Copied from transformers.models.bart.tokenization_bart.BartTokenizer.vocab_size
			def       SCREAMING_SNAKE_CASE   (			self   :      Optional[int]       )      ->      Optional[int]:
							return len(self.encoder       )






			def       SCREAMING_SNAKE_CASE   (			self   :      str       )      ->      List[Any]:
							return dict(self.encoder	,    **self.added_tokens_encoder       )






			def       SCREAMING_SNAKE_CASE   (			self   :      Any	,    __SCREAMING_SNAKE_CASE   :      int       )      ->      Union[str, Any]:
							if token in self.cache:
											return self.cache[token]
							a_		:	List[str]									=   tuple(__SCREAMING_SNAKE_CASE       )
							a_		:	List[Any]									=   get_pairs(__SCREAMING_SNAKE_CASE       )

							if not pairs:
											return token

							while True:
											a_		:	int									=   min(__SCREAMING_SNAKE_CASE	,    key=lambda __SCREAMING_SNAKE_CASE       : self.bpe_ranks.get(__SCREAMING_SNAKE_CASE	,    float('''inf'''       )       )       )
											if bigram not in self.bpe_ranks:
															break
											a_					,      a_		:	Optional[Any]									=   bigram
											a_		:	int									=   []
											a_		:	Dict									=   0
											while i < len(__SCREAMING_SNAKE_CASE       ):
															try:
																			a_		:	Optional[Any]									=   word.index(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE       )
															except ValueError:
																			new_word.extend(word[i:]       )
																			break
															else:
																			new_word.extend(word[i:j]       )
																			a_		:	Dict									=   j

															if word[i] == first and i < len(__SCREAMING_SNAKE_CASE       ) - 1 and word[i + 1] == second:
																			new_word.append(first + second       )
																			i += 2
															else:
																			new_word.append(word[i]       )
																			i += 1
											a_		:	Any									=   tuple(__SCREAMING_SNAKE_CASE       )
											a_		:	List[str]									=   new_word
											if len(__SCREAMING_SNAKE_CASE       ) == 1:
															break
											else:
															a_		:	List[Any]									=   get_pairs(__SCREAMING_SNAKE_CASE       )
							a_		:	str									=   ''' '''.join(__SCREAMING_SNAKE_CASE       )
							a_		:	Dict									=   word
							return word






			def       SCREAMING_SNAKE_CASE   (			self   :      Union[str, Any]	,    __SCREAMING_SNAKE_CASE   :      List[Any]       )      ->      Tuple:
							a_		:	Dict									=   []
							for token in re.findall(self.pat	,    __SCREAMING_SNAKE_CASE       ):
											a_		:	int									=   ''''''.join(
											    self.byte_encoder[b] for b in token.encode('''utf-8'''       )       )  # Maps all our bytes to unicode strings, avoiding control tokens of the BPE (spaces in our case)
											bpe_tokens.extend(bpe_token for bpe_token in self.bpe(__SCREAMING_SNAKE_CASE       ).split(''' '''       )       )
							return bpe_tokens






			def       SCREAMING_SNAKE_CASE   (			self   :      Optional[int]	,    __SCREAMING_SNAKE_CASE   :      Dict       )      ->      Dict:
							return self.encoder.get(__SCREAMING_SNAKE_CASE	,    self.encoder.get(self.unk_token       )       )






			def       SCREAMING_SNAKE_CASE   (			self   :      Tuple	,    __SCREAMING_SNAKE_CASE   :      str       )      ->      List[str]:
							return self.decoder.get(__SCREAMING_SNAKE_CASE       )






			def       SCREAMING_SNAKE_CASE   (			self   :      List[Any]	,    __SCREAMING_SNAKE_CASE   :      Tuple       )      ->      Optional[int]:
							a_		:	List[Any]									=   ''''''.join(__SCREAMING_SNAKE_CASE       )
							a_		:	str									=   bytearray([self.byte_decoder[c] for c in text]       ).decode('''utf-8'''	,    errors=self.errors       )
							return text






			def       SCREAMING_SNAKE_CASE   (			self   :      Optional[Any]	,    __SCREAMING_SNAKE_CASE   :      str	,    __SCREAMING_SNAKE_CASE   :      Optional[str] = None       )      ->      Tuple[str]:
							if not os.path.isdir(__SCREAMING_SNAKE_CASE       ):
											logger.error(f'Vocabulary path ({save_directory}) should be a directory'       )
											return
							a_		:	Tuple									=   os.path.join(
							    __SCREAMING_SNAKE_CASE	,    (filename_prefix + '''-''' if filename_prefix else '''''') + VOCAB_FILES_NAMES['''vocab_file''']       )
							a_		:	List[str]									=   os.path.join(
							    __SCREAMING_SNAKE_CASE	,    (filename_prefix + '''-''' if filename_prefix else '''''') + VOCAB_FILES_NAMES['''merges_file''']       )

							with open(__SCREAMING_SNAKE_CASE	,    '''w'''	,    encoding='''utf-8'''       ) as f:
											f.write(json.dumps(self.encoder	,    indent=2	,    sort_keys=__SCREAMING_SNAKE_CASE	,    ensure_ascii=__SCREAMING_SNAKE_CASE       ) + '''\n'''       )

							a_		:	Any									=   0
							with open(__SCREAMING_SNAKE_CASE	,    '''w'''	,    encoding='''utf-8'''       ) as writer:
											writer.write('''#version: 0.2\n'''       )
											for bpe_tokens, token_index in sorted(self.bpe_ranks.items()	,    key=lambda __SCREAMING_SNAKE_CASE       : kv[1]       ):
															if index != token_index:
																			logger.warning(
																			    f'Saving vocabulary to {merge_file}: BPE merge indices are not consecutive.'
																			    ''' Please check that the tokenizer is not corrupted!'''       )
																			a_		:	Any									=   token_index
															writer.write(''' '''.join(__SCREAMING_SNAKE_CASE       ) + '''\n'''       )
															index += 1

							return vocab_file, merge_file






			def       SCREAMING_SNAKE_CASE   (			self   :      Union[str, Any]	,    __SCREAMING_SNAKE_CASE   :      List[int]	,    __SCREAMING_SNAKE_CASE   :      Optional[List[int]] = None       )      ->      List[int]:
							if token_ids_a is None:
											return [self.cls_token_id] + token_ids_a + [self.sep_token_id]
							a_		:	Optional[Any]									=   [self.cls_token_id]
							a_		:	Tuple									=   [self.sep_token_id]
							return cls + token_ids_a + sep + sep + token_ids_a + sep






			def       SCREAMING_SNAKE_CASE   (			self   :      int	,    __SCREAMING_SNAKE_CASE   :      List[int]	,    __SCREAMING_SNAKE_CASE   :      Optional[List[int]] = None	,    __SCREAMING_SNAKE_CASE   :      bool = False       )      ->      List[int]:
							if already_has_special_tokens:
											return super().get_special_tokens_mask(
											    token_ids_a=__SCREAMING_SNAKE_CASE	,    token_ids_a=__SCREAMING_SNAKE_CASE	,    already_has_special_tokens=__SCREAMING_SNAKE_CASE       )

							if token_ids_a is None:
											return [1] + ([0] * len(__SCREAMING_SNAKE_CASE       )) + [1]
							return [1] + ([0] * len(__SCREAMING_SNAKE_CASE       )) + [1, 1] + ([0] * len(__SCREAMING_SNAKE_CASE       )) + [1]






			def       SCREAMING_SNAKE_CASE   (			self   :      Optional[Any]	,    __SCREAMING_SNAKE_CASE   :      List[int]	,    __SCREAMING_SNAKE_CASE   :      Optional[List[int]] = None       )      ->      List[int]:
							a_		:	Any									=   [self.sep_token_id]
							a_		:	Optional[Any]									=   [self.cls_token_id]

							if token_ids_a is None:
											return len(cls + token_ids_a + sep       ) * [0]
							return len(cls + token_ids_a + sep + sep + token_ids_a + sep       ) * [0]






			def       SCREAMING_SNAKE_CASE   (			self   :      str	,    __SCREAMING_SNAKE_CASE   :      str	,    __SCREAMING_SNAKE_CASE   :      Optional[Any]=False	,    **__SCREAMING_SNAKE_CASE   :      int       )      ->      Dict:
							a_		:	List[Any]									=   kwargs.pop('''add_prefix_space'''	,    self.add_prefix_space       )
							if (is_split_into_words or add_prefix_space) and (len(__SCREAMING_SNAKE_CASE       ) > 0 and not text[0].isspace()):
											a_		:	str									=   ''' ''' + text
							return (text, kwargs)







			def       SCREAMING_SNAKE_CASE   (			self   :      str	,    __SCREAMING_SNAKE_CASE   :      Union[Dict[str, EncodedInput], BatchEncoding]	,    __SCREAMING_SNAKE_CASE   :      Optional[int] = None	,    __SCREAMING_SNAKE_CASE   :      PaddingStrategy = PaddingStrategy.DO_NOT_PAD	,    __SCREAMING_SNAKE_CASE   :      Optional[int] = None	,    __SCREAMING_SNAKE_CASE   :      Optional[bool] = None	,    )      ->      dict:
							a_		:	List[str]									=   super()._pad(
							    encoded_inputs=__SCREAMING_SNAKE_CASE	,    max_length=__SCREAMING_SNAKE_CASE	,    padding_strategy=__SCREAMING_SNAKE_CASE	,    pad_to_multiple_of=__SCREAMING_SNAKE_CASE	,    return_attention_mask=__SCREAMING_SNAKE_CASE	,    )

							# Load from model defaults
							if return_attention_mask is None:
											a_		:	Tuple									=   '''attention_mask''' in self.model_input_names

							if return_attention_mask and "global_attention_mask" in encoded_inputs:
											a_		:	Tuple									=   encoded_inputs[self.model_input_names[0]]
											# `global_attention_mask` need to have the same length as other (sequential) inputs.
											a_		:	List[Any]									=   len(encoded_inputs['''global_attention_mask''']       ) != len(__SCREAMING_SNAKE_CASE       )

											if needs_to_be_padded:
															a_		:	int									=   len(__SCREAMING_SNAKE_CASE       ) - len(encoded_inputs['''global_attention_mask''']       )

															if self.padding_side == "right":
																			# Use `-1` since `0` in `global_attention_mask` means `local attention` instead of `not to attend`
																			a_		:	Optional[int]									=   (
																			    encoded_inputs['''global_attention_mask'''] + [-1] * difference
																			)
															elif self.padding_side == "left":
																			a_		:	List[Any]									=   [-1] * difference + encoded_inputs[
																			    '''global_attention_mask'''
																			]
															else:
																			raise ValueError('''Invalid padding strategy:''' + str(self.padding_side       )       )

							return encoded_inputs












'''simple docstring'''







import inspect
import os
import re

from transformers.configuration_utils import PretrainedConfig
from transformers.utils import direct_transformers_import


# All paths are set with the intent you should run this script from the root of the repo with the command
# python utils/check_config_docstrings.py
__lowerCAmelCase									=   'src/transformers'


# This is to make sure the transformers module imported is the one in the repo.
__lowerCAmelCase									=   direct_transformers_import(PATH_TO_TRANSFORMERS)

__lowerCAmelCase									=   transformers.models.auto.configuration_auto.CONFIG_MAPPING

__lowerCAmelCase									=   {
    # used to compute the property `self.chunk_length`
    'EncodecConfig': ['overlap'],
    # used as `self.bert_model = BertModel(config, ...)`
    'DPRConfig': True,
    # not used in modeling files, but it's an important information
    'FSMTConfig': ['langs'],
    # used internally in the configuration class file
    'GPTNeoConfig': ['attention_types'],
    # used internally in the configuration class file
    'EsmConfig': ['is_folding_model'],
    # used during training (despite we don't have training script for these models yet)
    'Mask2FormerConfig': ['ignore_value'],
    # `ignore_value` used during training (despite we don't have training script for these models yet)
    # `norm` used in conversion script (despite not using in the modeling file)
    'OneFormerConfig': ['ignore_value', 'norm'],
    # used during preprocessing and collation, see `collating_graphormer.py`
    'GraphormerConfig': ['spatial_pos_max'],
    # used internally in the configuration class file
    'T5Config': ['feed_forward_proj'],
    # used internally in the configuration class file
    # `tokenizer_class` get default value `T5Tokenizer` intentionally
    'MT5Config': ['feed_forward_proj', 'tokenizer_class'],
    'UMT5Config': ['feed_forward_proj', 'tokenizer_class'],
    # used internally in the configuration class file
    'LongT5Config': ['feed_forward_proj'],
    # used internally in the configuration class file
    'SwitchTransformersConfig': ['feed_forward_proj'],
    # having default values other than `1e-5` - we can't fix them without breaking
    'BioGptConfig': ['layer_norm_eps'],
    # having default values other than `1e-5` - we can't fix them without breaking
    'GLPNConfig': ['layer_norm_eps'],
    # having default values other than `1e-5` - we can't fix them without breaking
    'SegformerConfig': ['layer_norm_eps'],
    # having default values other than `1e-5` - we can't fix them without breaking
    'CvtConfig': ['layer_norm_eps'],
    # having default values other than `1e-5` - we can't fix them without breaking
    'PerceiverConfig': ['layer_norm_eps'],
    # used internally to calculate the feature size
    'InformerConfig': ['num_static_real_features', 'num_time_features'],
    # used internally to calculate the feature size
    'TimeSeriesTransformerConfig': ['num_static_real_features', 'num_time_features'],
    # used internally to calculate the feature size
    'AutoformerConfig': ['num_static_real_features', 'num_time_features'],
    # used internally to calculate `mlp_dim`
    'SamVisionConfig': ['mlp_ratio'],
    # For (head) training, but so far not implemented
    'ClapAudioConfig': ['num_classes'],
    # Not used, but providing useful information to users
    'SpeechT5HifiGanConfig': ['sampling_rate'],
}


# TODO (ydshieh): Check the failing cases, try to fix them or move some cases to the above block once we are sure
SPECIAL_CASES_TO_ALLOW.update(
    {
        'CLIPSegConfig': True,
        'DeformableDetrConfig': True,
        'DetaConfig': True,
        'DinatConfig': True,
        'DonutSwinConfig': True,
        'EfficientFormerConfig': True,
        'FSMTConfig': True,
        'JukeboxConfig': True,
        'LayoutLMv2Config': True,
        'MaskFormerSwinConfig': True,
        'MT5Config': True,
        'NatConfig': True,
        'OneFormerConfig': True,
        'PerceiverConfig': True,
        'RagConfig': True,
        'SpeechT5Config': True,
        'SwinConfig': True,
        'Swin2SRConfig': True,
        'Swinv2Config': True,
        'SwitchTransformersConfig': True,
        'TableTransformerConfig': True,
        'TapasConfig': True,
        'TransfoXLConfig': True,
        'UniSpeechConfig': True,
        'UniSpeechSatConfig': True,
        'WavLMConfig': True,
        'WhisperConfig': True,
        # TODO: @Arthur (for `alignment_head` and `alignment_layer`)
        'JukeboxPriorConfig': True,
        # TODO: @Younes (for `is_decoder`)
        'Pix2StructTextConfig': True,
    }
)





def 		_UpperCAmelCase (				__A				: Optional[Any]    ,		__A				: List[str]    ,		__A				: List[str]    ,		__A				: Union[str, Any]   ):
				a_		:	List[str]									=   False
				for attribute in attributes:
								for modeling_source in source_strings:
												# check if we can find `config.xxx`, `getattr(config, "xxx", ...)` or `getattr(self.config, "xxx", ...)`
												if (
												    f'config.{attribute}' in modeling_source
												    or f'getattr(config, "{attribute}"' in modeling_source
												    or f'getattr(self.config, "{attribute}"' in modeling_source
												):
																a_		:	Tuple									=   True
												# Deal with multi-line cases
												elif (
												    re.search(
												        Rf'getattr[ \t\v\n\r\f]*\([ \t\v\n\r\f]*(self\.)?config,[ \t\v\n\r\f]*"{attribute}"'    ,		__A    ,		)
												    is not None
												):
																a_		:	Union[str, Any]									=   True
												# `SequenceSummary` is called with `SequenceSummary(config)`
												elif attribute in [
												    "summary_type",
												    "summary_use_proj",
												    "summary_activation",
												    "summary_last_dropout",
												    "summary_proj_to_labels",
												    "summary_first_dropout",
												]:
																if "SequenceSummary" in modeling_source:
																				a_		:	Any									=   True
												if attribute_used:
																break
								if attribute_used:
												break

    # common and important attributes, even if they do not always appear in the modeling files
				a_		:	Tuple									=   [
				    '''bos_index''',
				    '''eos_index''',
				    '''pad_index''',
				    '''unk_index''',
				    '''mask_index''',
				    '''image_size''',
				    '''use_cache''',
				    '''out_features''',
				    '''out_indices''',
				]
				a_		:	Tuple									=   ['''encoder_no_repeat_ngram_size''']

				# Special cases to be allowed
				a_		:	Optional[int]									=   True
				if not attribute_used:
								a_		:	Optional[Any]									=   False
								for attribute in attributes:
												# Allow if the default value in the configuration class is different from the one in `PretrainedConfig`
												if attribute in ["is_encoder_decoder"] and default_value is True:
																a_		:	Dict									=   True
												elif attribute in ["tie_word_embeddings"] and default_value is False:
																a_		:	List[str]									=   True

												# Allow cases without checking the default value in the configuration class
												elif attribute in attributes_to_allow + attributes_used_in_generation:
																a_		:	Optional[int]									=   True
												elif attribute.endswith('''_token_id'''   ):
																a_		:	Tuple									=   True

												# configuration class specific cases
												if not case_allowed:
																a_		:	Dict									=   SPECIAL_CASES_TO_ALLOW.get(config_class.__name__    ,		[]   )
																a_		:	int									=   allowed_cases is True or attribute in allowed_cases

				return attribute_used or case_allowed





def 		_UpperCAmelCase (				__A				: Union[str, Any]   ):
				a_		:	str									=   dict(inspect.signature(config_class.__init__   ).parameters   )
				a_		:	List[str]									=   [x for x in list(signature.keys()   ) if x not in ['''self''', '''kwargs''']]
				a_		:	Optional[Any]									=   [signature[param].default for param in parameter_names]

				# If `attribute_map` exists, an attribute can have different names to be used in the modeling files, and as long
				# as one variant is used, the test should pass
				a_		:	int									=   {}
				if len(config_class.attribute_map   ) > 0:
								a_		:	List[str]									=   {v: k for k, v in config_class.attribute_map.items()}

				# Get the path to modeling source files
				a_		:	Tuple									=   inspect.getsourcefile(__A   )
				a_		:	str									=   os.path.dirname(__A   )
				# Let's check against all frameworks: as long as one framework uses an attribute, we are good.
				a_		:	Tuple									=   [os.path.join(__A    ,		__A   ) for fn in os.listdir(__A   ) if fn.startswith('''modeling_'''   )]

				# Get the source code strings
				a_		:	Dict									=   []
				for path in modeling_paths:
								if os.path.isfile(__A   ):
												with open(__A   ) as fp:
																modeling_sources.append(fp.read()   )

				a_		:	List[Any]									=   []
				for config_param, default_value in zip(__A    ,		__A   ):
								# `attributes` here is all the variant names for `config_param`
								a_		:	int									=   [config_param]
								# some configuration classes have non-empty `attribute_map`, and both names could be used in the
								# corresponding modeling files. As long as one of them appears, it is fine.
								if config_param in reversed_attribute_map:
												attributes.append(reversed_attribute_map[config_param]   )

								if not check_attribute_being_used(__A    ,		__A    ,		__A    ,		__A   ):
												unused_attributes.append(attributes[0]   )

				return sorted(__A   )





def 		_UpperCAmelCase (				):
				a_		:	Optional[int]									=   {}
				for _config_class in list(CONFIG_MAPPING.values()   ):
								# Skip deprecated models
								if "models.deprecated" in _config_class.__module__:
												continue
								# Some config classes are not in `CONFIG_MAPPING` (e.g. `CLIPVisionConfig`, `Blip2VisionConfig`, etc.)
								a_		:	int									=   [
								    cls
								    for name, cls in inspect.getmembers(
								        inspect.getmodule(_config_class   )    ,		lambda __A   : inspect.isclass(__A   )
								        and issubclass(__A    ,		__A   )
								        and inspect.getmodule(__A   ) == inspect.getmodule(_config_class   )    ,		)
								]
								for config_class in config_classes_in_module:
												a_		:	int									=   check_config_attributes_being_used(__A   )
												if len(__A   ) > 0:
																a_		:	Dict									=   unused_attributes

				if len(__A   ) > 0:
								a_		:	Dict									=   '''The following configuration classes contain unused attributes in the corresponding modeling files:\n'''
								for name, attributes in configs_with_unused_attributes.items():
												error += f'{name}: {attributes}\n'

								raise ValueError(__A   )


if __name__ == "__main__":
		check_config_attributes()




