

'''simple docstring'''



import warnings

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



class lowerCamelCase			(  _UpperCamelCase						):



			'''simple docstring'''






			__snake_case        =	['image_processor', 'tokenizer']
			__snake_case        =	'ChineseCLIPImageProcessor'
			__snake_case        =	('BertTokenizer', 'BertTokenizerFast')


			def __init__(				self	:						List[Any]		,      lowerCAmelCase_	:						List[Any]=None		,      lowerCAmelCase_	:						int=None		,      **lowerCAmelCase_	:						List[str]			)      ->		Any:





									'''simple docstring'''
									A__					:       Optional[int]     =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		,      )
															A__					:       List[str]     =kwargs.pop("""feature_extractor"""			)

									A__					:       List[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__(_SCREAMING_SNAKE_CASE		,      _SCREAMING_SNAKE_CASE			)
									A__					:       Dict     =self.image_processor


			def __call__(				self	:						int		,      lowerCAmelCase_	:						Optional[Any]=None		,      lowerCAmelCase_	:						List[str]=None		,      lowerCAmelCase_	:						Optional[Any]=None		,      **lowerCAmelCase_	:						str			)      ->		Optional[Any]:





									'''simple docstring'''

									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__					:       Union[str, Any]     =self.tokenizer(_SCREAMING_SNAKE_CASE		,      return_tensors=_SCREAMING_SNAKE_CASE		,      **_SCREAMING_SNAKE_CASE			)

									if images is not None:
															A__					:       List[str]     =self.image_processor(_SCREAMING_SNAKE_CASE		,      return_tensors=_SCREAMING_SNAKE_CASE		,      **_SCREAMING_SNAKE_CASE			)

									if text is not None and images is not None:
															A__					:       str     =image_features.pixel_values
															return encoding
									elif text is not None:
															return encoding
									else:
															return BatchEncoding(data=dict(**_SCREAMING_SNAKE_CASE			)		,      tensor_type=_SCREAMING_SNAKE_CASE			)


			def lowercase__						(				self	:						Optional[int]		,      *lowerCAmelCase_	:						Tuple		,      **lowerCAmelCase_	:						Union[str, Any]			)      ->		Dict:





									'''simple docstring'''
									return self.tokenizer.batch_decode(*_SCREAMING_SNAKE_CASE		,      **_SCREAMING_SNAKE_CASE			)


			def lowercase__						(				self	:						List[str]		,      *lowerCAmelCase_	:						Tuple		,      **lowerCAmelCase_	:						Union[str, Any]			)      ->		Any:





									'''simple docstring'''
									return self.tokenizer.decode(*_SCREAMING_SNAKE_CASE		,      **_SCREAMING_SNAKE_CASE			)


			@property
			def lowercase__						(				self	:						Dict			)      ->		Optional[int]:





									'''simple docstring'''
									A__					:       Optional[Any]     =self.tokenizer.model_input_names
									A__					:       Any     =self.image_processor.model_input_names
									return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names			)			)



			@property
			def lowercase__						(				self	:						Optional[int]			)      ->		Optional[int]:





									'''simple docstring'''
									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




'''simple docstring'''



from argparse import ArgumentParser

from .add_new_model import AddNewModelCommand
from .add_new_model_like import AddNewModelLikeCommand
from .convert import ConvertCommand
from .download import DownloadCommand
from .env import EnvironmentCommand
from .lfs import LfsCommands
from .pt_to_tf import PTtoTFCommand
from .run import RunCommand
from .serving import ServeCommand
from .user import UserCommands
def 						__lowerCamelCase	(       )	->							List[Any]:






						"""simple docstring"""





						A__					:       List[Any]     =ArgumentParser("""Transformers CLI tool""",		usage="""transformers-cli <command> [<args>]"""	)
						A__					:       List[Any]     =parser.add_subparsers(help="""transformers-cli command helpers"""	)

						# Register commands
						ConvertCommand.register_subcommand(__snake_case	)
						DownloadCommand.register_subcommand(__snake_case	)
						EnvironmentCommand.register_subcommand(__snake_case	)
						RunCommand.register_subcommand(__snake_case	)
						ServeCommand.register_subcommand(__snake_case	)
						UserCommands.register_subcommand(__snake_case	)
						AddNewModelCommand.register_subcommand(__snake_case	)
						AddNewModelLikeCommand.register_subcommand(__snake_case	)
						LfsCommands.register_subcommand(__snake_case	)
						PTtoTFCommand.register_subcommand(__snake_case	)

						# Let's go
						A__					:       List[str]     =parser.parse_args()

						if not hasattr(__snake_case,		"""func"""	):
												parser.print_help()
												exit(1	)

						# Run
						A__					:       Optional[Any]     =args.func(__snake_case	)
						service.run()


if __name__ == "__main__":
		main()

