



'''simple docstring'''

import warnings

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

class 	__magic_name__						(    _UpperCamelCase   ):
							lowerCAmelCase       :    Optional[int]   				=					['image_processor', 'tokenizer']
							lowerCAmelCase       :    List[str]   				=					'CLIPImageProcessor'
							lowerCAmelCase       :    Union[str, Any]   				=					('XLMRobertaTokenizer', 'XLMRobertaTokenizerFast')







							def __init__(							self					:       Dict	,_UpperCAmelCase					:       Tuple=None	,_UpperCAmelCase					:       int=None	,**_UpperCAmelCase					:       str		):
									_a     :      List[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.'	,_UpperCAmelCase	,)
											_a     :      Dict        =							kwargs.pop('feature_extractor'		)

									_a     :      Optional[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__(_UpperCAmelCase	,_UpperCAmelCase		)







							def __call__(							self					:       Union[str, Any]	,_UpperCAmelCase					:       Dict=None	,_UpperCAmelCase					:       List[str]=None	,_UpperCAmelCase					:       Optional[Any]=None	,**_UpperCAmelCase					:       Optional[Any]		):

									if text is None and images is None:
											raise ValueError('You have to specify either text or images. Both cannot be none.'		)

									if text is not None:
											_a     :      int        =							self.tokenizer(_UpperCAmelCase	,return_tensors=_UpperCAmelCase	,**_UpperCAmelCase		)

									if images is not None:
											_a     :      Dict        =							self.image_processor(_UpperCAmelCase	,return_tensors=_UpperCAmelCase	,**_UpperCAmelCase		)

									if text is not None and images is not None:
											_a     :      Optional[int]        =							image_features.pixel_values
											return encoding
									elif text is not None:
											return encoding
									else:
											return BatchEncoding(data=dict(**_UpperCAmelCase		)	,tensor_type=_UpperCAmelCase		)







							def 							__lowercase			(							self					:       int	,*_UpperCAmelCase					:       List[Any]	,**_UpperCAmelCase					:       Dict		):
									return self.tokenizer.batch_decode(*_UpperCAmelCase	,**_UpperCAmelCase		)







							def 							__lowercase			(							self					:       Optional[int]	,*_UpperCAmelCase					:       Any	,**_UpperCAmelCase					:       Dict		):
									return self.tokenizer.decode(*_UpperCAmelCase	,**_UpperCAmelCase		)







							@property
							def 							__lowercase			(							self					:       Any		):
									_a     :      Tuple        =							self.tokenizer.model_input_names
									_a     :      Tuple        =							self.image_processor.model_input_names
									return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names		)		)









'''simple docstring'''

import doctest
import logging
import os
import unittest
from pathlib import Path
from typing import List, Union

import transformers
from transformers.testing_utils import require_tf, require_torch, slow


__lowerCAmelCase									=   logging.getLogger()

@unittest.skip('Temporarily disable the doc tests.'   )
@require_torch
@require_tf
@slow
class 	__magic_name__						(    unittest.TestCase   ):







							def 							__lowercase			(							self					:       str	,_UpperCAmelCase					:       Path	,_UpperCAmelCase					:       Union[str, None] = None	,_UpperCAmelCase					:       Union[List[str], None] = None	,_UpperCAmelCase					:       Union[str, List[str], None] = None	,_UpperCAmelCase					:       bool = True	,):
									_a     :      Dict        =							[file for file in os.listdir(_UpperCAmelCase		) if os.path.isfile(os.path.join(_UpperCAmelCase	,_UpperCAmelCase		)		)]

									if identifier is not None:
											_a     :      str        =							[file for file in files if identifier in file]

									if n_identifier is not None:
											if isinstance(_UpperCAmelCase	,_UpperCAmelCase		):
													for n_ in n_identifier:
															_a     :      int        =							[file for file in files if n_ not in file]
											else:
													_a     :      Optional[Any]        =							[file for file in files if n_identifier not in file]

									_a     :      Dict        =							ignore_files or []
									ignore_files.append('__init__.py'		)
									_a     :      List[str]        =							[file for file in files if file not in ignore_files]

									for file in files:
											# Open all files
											print('Testing'	,_UpperCAmelCase		)

											if only_modules:
													_a     :      Any        =							file.split('.'		)[0]
													try:
															_a     :      Optional[int]        =							getattr(_UpperCAmelCase	,_UpperCAmelCase		)
															_a     :      Dict        =							doctest.DocTestSuite(_UpperCAmelCase		)
															_a     :      Optional[int]        =							unittest.TextTestRunner().run(_UpperCAmelCase		)
															self.assertIs(len(result.failures		)	,0		)
													except AttributeError:
															logger.info(F"""{module_identifier} is not a module."""		)
											else:
													_a     :      str        =							doctest.testfile(str('..' / directory / file		)	,optionflags=doctest.ELLIPSIS		)
													self.assertIs(result.failed	,0		)







							def 							__lowercase			(							self					:       Union[str, Any]		):
									_a     :      Optional[Any]        =							Path('src/transformers'		)
									_a     :      Optional[Any]        =							'modeling'
									_a     :      Union[str, Any]        =							[
									    'modeling_ctrl.py',
									    'modeling_tf_ctrl.py',
									]
									self.analyze_directory(_UpperCAmelCase	,identifier=_UpperCAmelCase	,ignore_files=_UpperCAmelCase		)







							def 							__lowercase			(							self					:       int		):
									_a     :      str        =							Path('src/transformers'		)
									_a     :      List[str]        =							'tokenization'
									self.analyze_directory(_UpperCAmelCase	,identifier=_UpperCAmelCase		)







							def 							__lowercase			(							self					:       int		):
									_a     :      Any        =							Path('src/transformers'		)
									_a     :      str        =							'configuration'
									self.analyze_directory(_UpperCAmelCase	,identifier=_UpperCAmelCase		)







							def 							__lowercase			(							self					:       Dict		):
									_a     :      Tuple        =							Path('src/transformers'		)
									_a     :      Optional[int]        =							['configuration', 'modeling', 'tokenization']
									self.analyze_directory(_UpperCAmelCase	,n_identifier=_UpperCAmelCase		)







							def 							__lowercase			(							self					:       Optional[Any]		):
									_a     :      Union[str, Any]        =							Path('docs/source'		)
									_a     :      List[str]        =							['favicon.ico']
									self.analyze_directory(_UpperCAmelCase	,ignore_files=_UpperCAmelCase	,only_modules=_UpperCAmelCase		)




