
import copy

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


_SCREAMING_SNAKE_CASE     :   List[Any]							 =      logging.get_logger(__name__)







class 			UpperCamelCase__		(     snake_case_ ):







	'''simple docstring'''
	_lowerCAmelCase											=					"hybrid-clip"
	_lowerCAmelCase											=					True





	def __init__(      self					,							UpperCamelCase__=512					,							**UpperCamelCase__		):
					super().__init__(**_A		)

					if "text_config" not in kwargs:
									raise ValueError('''`text_config` can not be `None`.'''		)

					if "vision_config" not in kwargs:
									raise ValueError('''`vision_config` can not be `None`.'''		)

					A__	:						List[Any]								=				kwargs.pop('''text_config'''		)
					A__	:						int								=				kwargs.pop('''vision_config'''		)

					A__	:						Optional[Any]								=				text_config.pop('''model_type'''		)
					A__	:						Optional[Any]								=				vision_config.pop('''model_type'''		)

					from transformers import AutoConfig

					A__	:						List[str]								=				AutoConfig.for_model(_A					,							**_A		)

					if vision_model_type == "clip":
									A__	:						Optional[Any]								=				AutoConfig.for_model(_A					,							**_A		).vision_config
					elif vision_model_type == "clip_vision_model":
									from transformers import CLIPVisionConfig

									A__	:						Optional[Any]								=				CLIPVisionConfig(**_A		)
					else:
									A__	:						List[Any]								=				AutoConfig.for_model(_A					,							**_A		)

					A__	:						Tuple								=				projection_dim
					A__	:						Dict								=				1.0





	@classmethod
	def 	__snake_case					(      cls					,							UpperCamelCase__					,							UpperCamelCase__					,							**UpperCamelCase__		):
					return cls(text_config=text_config.to_dict()					,							vision_config=vision_config.to_dict()					,							**_A		)





	def 	__snake_case					(      self		):
					A__	:						Optional[int]								=				copy.deepcopy(self.__dict__		)
					A__	:						Union[str, Any]								=				self.text_config.to_dict()
					A__	:						Any								=				self.vision_config.to_dict()
					A__	:						Any								=				self.__class__.model_type
					return output






import os
import shutil
import unittest
from unittest.mock import patch

from transformers.testing_utils import CaptureStd, is_pt_tf_cross_test, require_torch
class SCREAMING_SNAKE_CASE_    (       unittest.TestCase       ):






						@patch('sys.argv'		, ['fakeprogrampath', 'env']						)
						def UpperCAmelCase_					(   self   :   Tuple						)				->     Dict:







							"""simple docstring"""


							import transformers.commands.transformers_cli

							with CaptureStd() as cs:
								transformers.commands.transformers_cli.main()
							self.assertIn('Python version'		, cs.out						)
							self.assertIn('Platform'		, cs.out						)
							self.assertIn('Using distributed or parallel set-up in script?'		, cs.out						)






						@is_pt_tf_cross_test
						@patch(
						    'sys.argv'		, ['fakeprogrampath', 'pt-to-tf', '--model-name', 'hf-internal-testing/tiny-random-gptj', '--no-pr']						)
						def UpperCAmelCase_					(   self   :   Union[str, Any]						)				->     Optional[Any]:







							"""simple docstring"""


							import transformers.commands.transformers_cli

							shutil.rmtree('/tmp/hf-internal-testing/tiny-random-gptj'		, ignore_errors=_A						)  # cleans potential past runs
							transformers.commands.transformers_cli.main()

							# The original repo has no TF weights -- if they exist, they were created by the CLI
							self.assertTrue(os.path.exists('/tmp/hf-internal-testing/tiny-random-gptj/tf_model.h5'						)						)






						@require_torch
						@patch('sys.argv'		, ['fakeprogrampath', 'download', 'hf-internal-testing/tiny-random-gptj', '--cache-dir', '/tmp']						)
						def UpperCAmelCase_					(   self   :   List[Any]						)				->     str:







							"""simple docstring"""


							import transformers.commands.transformers_cli

							# # remove any previously downloaded model to start clean
							shutil.rmtree('/tmp/models--hf-internal-testing--tiny-random-gptj'		, ignore_errors=_A						)

							# run the command
							transformers.commands.transformers_cli.main()

							# check if the model files are downloaded correctly on /tmp/models--hf-internal-testing--tiny-random-gptj
							self.assertTrue(os.path.exists('/tmp/models--hf-internal-testing--tiny-random-gptj/blobs'						)						)
							self.assertTrue(os.path.exists('/tmp/models--hf-internal-testing--tiny-random-gptj/refs'						)						)
							self.assertTrue(os.path.exists('/tmp/models--hf-internal-testing--tiny-random-gptj/snapshots'						)						)






						@require_torch
						@patch(
						    'sys.argv'		, [
						        'fakeprogrampath',
						        'download',
						        'hf-internal-testing/test_dynamic_model_with_tokenizer',
						        '--trust-remote-code',
						        '--cache-dir',
						        '/tmp',
						    ]		, )
						def UpperCAmelCase_					(   self   :   Optional[Any]						)				->     str:







							"""simple docstring"""


							import transformers.commands.transformers_cli

							# # remove any previously downloaded model to start clean
							shutil.rmtree('/tmp/models--hf-internal-testing--test_dynamic_model_with_tokenizer'		, ignore_errors=_A						)

							# run the command
							transformers.commands.transformers_cli.main()

							# check if the model files are downloaded correctly on /tmp/models--hf-internal-testing--test_dynamic_model_with_tokenizer
							self.assertTrue(os.path.exists('/tmp/models--hf-internal-testing--test_dynamic_model_with_tokenizer/blobs'						)						)
							self.assertTrue(os.path.exists('/tmp/models--hf-internal-testing--test_dynamic_model_with_tokenizer/refs'						)						)
							self.assertTrue(
							    os.path.exists('/tmp/models--hf-internal-testing--test_dynamic_model_with_tokenizer/snapshots'						)						)

