
'''simple docstring'''





import warnings

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding

class 						a   (				__magic_name__    ):
				_snake_case		    = ['''image_processor''', '''tokenizer''']
				_snake_case		    = '''ViTImageProcessor'''
				_snake_case		    = ('''CLIPTokenizer''', '''CLIPTokenizerFast''')




				def __init__(							self	:				Tuple,    SCREAMING_SNAKE_CASE_	:				List[Any]=None,    SCREAMING_SNAKE_CASE_	:				List[Any]=None,    **SCREAMING_SNAKE_CASE_	:				str      ):
										snake_case       :     List[Any] =    None
										if "feature_extractor" in kwargs:
																warnings.warn(
																    '''The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`'''
																    ''' instead.''',    SCREAMING_SNAKE_CASE_,    )
																snake_case       :     List[str] =    kwargs.pop('''feature_extractor'''      )

										snake_case       :     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__(SCREAMING_SNAKE_CASE_,    SCREAMING_SNAKE_CASE_      )




				def __call__(							self	:				Optional[Any],    SCREAMING_SNAKE_CASE_	:				Dict=None,    SCREAMING_SNAKE_CASE_	:				Tuple=None,    SCREAMING_SNAKE_CASE_	:				Dict=None,    SCREAMING_SNAKE_CASE_	:				Optional[int]=None,    **SCREAMING_SNAKE_CASE_	:				Any      ):
										if text is None and visual_prompt is None and images is None:
																raise ValueError('''You have to specify either text, visual prompt or images.'''      )

										if text is not None and visual_prompt is not None:
																raise ValueError('''You have to specify exactly one type of prompt. Either text or visual prompt.'''      )

										if text is not None:
																snake_case       :     List[str] =    self.tokenizer(SCREAMING_SNAKE_CASE_,    return_tensors=SCREAMING_SNAKE_CASE_,    **SCREAMING_SNAKE_CASE_      )

										if visual_prompt is not None:
																snake_case       :     Optional[int] =    self.image_processor(SCREAMING_SNAKE_CASE_,    return_tensors=SCREAMING_SNAKE_CASE_,    **SCREAMING_SNAKE_CASE_      )

										if images is not None:
																snake_case       :     int =    self.image_processor(SCREAMING_SNAKE_CASE_,    return_tensors=SCREAMING_SNAKE_CASE_,    **SCREAMING_SNAKE_CASE_      )

										if visual_prompt is not None and images is not None:
																snake_case       :     Union[str, Any] =    {
																    '''pixel_values''': image_features.pixel_values,
																    '''conditional_pixel_values''': prompt_features.pixel_values,
																}
																return encoding
										elif text is not None and images is not None:
																snake_case       :     int =    image_features.pixel_values
																return encoding
										elif text is not None:
																return encoding
										elif visual_prompt is not None:
																snake_case       :     Dict =    {
																    '''conditional_pixel_values''': prompt_features.pixel_values,
																}
																return encoding
										else:
																return BatchEncoding(data=dict(**SCREAMING_SNAKE_CASE_      ),    tensor_type=SCREAMING_SNAKE_CASE_      )




				def 	__snake_case							(							self	:				List[str],    *SCREAMING_SNAKE_CASE_	:				List[Any],    **SCREAMING_SNAKE_CASE_	:				Optional[int]      ):
										return self.tokenizer.batch_decode(*SCREAMING_SNAKE_CASE_,    **SCREAMING_SNAKE_CASE_      )




				def 	__snake_case							(							self	:				int,    *SCREAMING_SNAKE_CASE_	:				Optional[Any],    **SCREAMING_SNAKE_CASE_	:				Any      ):
										return self.tokenizer.decode(*SCREAMING_SNAKE_CASE_,    **SCREAMING_SNAKE_CASE_      )




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




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



'''simple docstring'''





import inspect
import re

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
UpperCAmelCase    					=   "src/transformers"


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

UpperCAmelCase    					=   transformers.models.auto.configuration_auto.CONFIG_MAPPING

# Regex pattern used to find the checkpoint mentioned in the docstring of `config_class`.
# For example, `[bert-base-uncased](https://huggingface.co/bert-base-uncased)`
UpperCAmelCase    					=   re.compile(r"\[(.+?)\]\((https://huggingface\.co/.+?)\)")


UpperCAmelCase    					=   {
    "DecisionTransformerConfig",
    "EncoderDecoderConfig",
    "MusicgenConfig",
    "RagConfig",
    "SpeechEncoderDecoderConfig",
    "TimmBackboneConfig",
    "VisionEncoderDecoderConfig",
    "VisionTextDualEncoderConfig",
    "LlamaConfig",
}

def      A (       A_							:					Union[str, Any]       ):
						snake_case       :     Tuple =    None

						# source code of `config_class`
						snake_case       :     Union[str, Any] =    inspect.getsource(A_       )
						snake_case       :     List[Any] =    _re_checkpoint.findall(A_       )

						# Each `checkpoint` is a tuple of a checkpoint name and a checkpoint link.
						# For example, `('bert-base-uncased', 'https://huggingface.co/bert-base-uncased')`
						for ckpt_name, ckpt_link in checkpoints:
												# allow the link to end with `/`
												if ckpt_link.endswith('''/'''       ):
																		snake_case       :     Optional[int] =    ckpt_link[:-1]

												# verify the checkpoint name corresponds to the checkpoint link
												snake_case       :     Dict =    F"""https://huggingface.co/{ckpt_name}"""
												if ckpt_link == ckpt_link_from_name:
																		snake_case       :     Dict =    ckpt_name
																		break

						return checkpoint

def      A (       ):
						snake_case       :     List[str] =    []

						for config_class in list(CONFIG_MAPPING.values()       ):
												# Skip deprecated models
												if "models.deprecated" in config_class.__module__:
																		continue
												snake_case       :     Tuple =    get_checkpoint_from_config_class(A_       )

												snake_case       :     Optional[Any] =    config_class.__name__
												if checkpoint is None and name not in CONFIG_CLASSES_TO_IGNORE_FOR_DOCSTRING_CHECKPOINT_CHECK:
																		configs_without_checkpoint.append(A_       )

						if len(A_       ) > 0:
												snake_case       :     Optional[int] =    '''\n'''.join(sorted(A_       )       )
												raise ValueError(F"""The following configurations don't contain any valid checkpoint:\n{message}"""       )


if __name__ == "__main__":
						check_config_docstrings_have_checkpoints()

