





'''simple docstring'''




import copy

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


__UpperCAmelCase         =   logging.get_logger(__name__)

__UpperCAmelCase         =   {}




class       UpperCamelCase__			(			lowercase_	):




					"""simple docstring"""
					SCREAMING_SNAKE_CASE__						=					'''fsmt_decoder'''


					def __init__(		self							:	List[str]     ,		lowerCamelCase_							:	Tuple=0     ,		lowerCamelCase_							:	Optional[int]=0		):

							'''simple docstring'''



							super().__init__()
							SCREAMING_SNAKE_CASE				:							List[str]						=	vocab_size
							SCREAMING_SNAKE_CASE				:							Optional[Any]						=	bos_token_id







class       UpperCamelCase__			(			lowercase_	):




					"""simple docstring"""
					SCREAMING_SNAKE_CASE__						=					'''fsmt'''
					SCREAMING_SNAKE_CASE__						=					{'''num_attention_heads''': '''encoder_attention_heads''', '''hidden_size''': '''d_model'''}


					def __init__(		self							:	Optional[int]     ,		lowerCamelCase_							:	Optional[int]=["en", "de"]     ,		lowerCamelCase_							:	Union[str, Any]=4_20_24     ,		lowerCamelCase_							:	Union[str, Any]=4_20_24     ,		lowerCamelCase_							:	Any="relu"     ,		lowerCamelCase_							:	Union[str, Any]=10_24     ,		lowerCamelCase_							:	Dict=2_00     ,		lowerCamelCase_							:	Optional[int]=10_24     ,		lowerCamelCase_							:	List[str]=40_96     ,		lowerCamelCase_							:	Dict=12     ,		lowerCamelCase_							:	Tuple=16     ,		lowerCamelCase_							:	int=0.0     ,		lowerCamelCase_							:	str=40_96     ,		lowerCamelCase_							:	List[str]=12     ,		lowerCamelCase_							:	int=16     ,		lowerCamelCase_							:	List[Any]=0.0     ,		lowerCamelCase_							:	List[Any]=0.0     ,		lowerCamelCase_							:	str=0.1     ,		lowerCamelCase_							:	List[Any]=0.0     ,		lowerCamelCase_							:	Tuple=0.02     ,		lowerCamelCase_							:	List[str]=2     ,		lowerCamelCase_							:	Any=True     ,		lowerCamelCase_							:	Tuple=True     ,		lowerCamelCase_							:	List[Any]=False     ,		lowerCamelCase_							:	int=5     ,		lowerCamelCase_							:	Union[str, Any]=1.0     ,		lowerCamelCase_							:	int=False     ,		lowerCamelCase_							:	int=True     ,		lowerCamelCase_							:	List[Any]=1     ,		lowerCamelCase_							:	Any=0     ,		lowerCamelCase_							:	Optional[int]=2     ,		lowerCamelCase_							:	Optional[Any]=2     ,		**lowerCamelCase_							:	Optional[int]     ,		):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE				:							str						=	langs
							SCREAMING_SNAKE_CASE				:							Optional[int]						=	src_vocab_size
							SCREAMING_SNAKE_CASE				:							List[Any]						=	tgt_vocab_size
							SCREAMING_SNAKE_CASE				:							List[str]						=	d_model  # encoder_embed_dim and decoder_embed_dim

							SCREAMING_SNAKE_CASE				:							List[str]						=	encoder_ffn_dim
							SCREAMING_SNAKE_CASE				:							Tuple						=	encoder_layers
							SCREAMING_SNAKE_CASE				:							Dict						=	encoder_attention_heads
							SCREAMING_SNAKE_CASE				:							str						=	encoder_layerdrop
							SCREAMING_SNAKE_CASE				:							Any						=	decoder_layerdrop
							SCREAMING_SNAKE_CASE				:							Union[str, Any]						=	decoder_ffn_dim
							SCREAMING_SNAKE_CASE				:							Tuple						=	decoder_layers
							SCREAMING_SNAKE_CASE				:							Optional[int]						=	decoder_attention_heads
							SCREAMING_SNAKE_CASE				:							Any						=	max_position_embeddings
							SCREAMING_SNAKE_CASE				:							Tuple						=	init_std  # Normal(0, this parameter)
							SCREAMING_SNAKE_CASE				:							List[Any]						=	activation_function

							SCREAMING_SNAKE_CASE				:							Tuple						=	DecoderConfig(vocab_size=lowerCamelCase_     ,		bos_token_id=lowerCamelCase_		)
							if "decoder" in common_kwargs:
									del common_kwargs["decoder"]

							SCREAMING_SNAKE_CASE				:							Optional[int]						=	scale_embedding  # scale factor will be sqrt(d_model) if True

							# 3 Types of Dropout
							SCREAMING_SNAKE_CASE				:							Optional[int]						=	attention_dropout
							SCREAMING_SNAKE_CASE				:							Union[str, Any]						=	activation_dropout
							SCREAMING_SNAKE_CASE				:							Optional[Any]						=	dropout

							SCREAMING_SNAKE_CASE				:							Optional[int]						=	use_cache
							super().__init__(
							    pad_token_id=lowerCamelCase_     ,		bos_token_id=lowerCamelCase_     ,		eos_token_id=lowerCamelCase_     ,		decoder_start_token_id=lowerCamelCase_     ,		is_encoder_decoder=lowerCamelCase_     ,		tie_word_embeddings=lowerCamelCase_     ,		forced_eos_token_id=lowerCamelCase_     ,		max_length=lowerCamelCase_     ,		num_beams=lowerCamelCase_     ,		length_penalty=lowerCamelCase_     ,		early_stopping=lowerCamelCase_     ,		**lowerCamelCase_     ,		)



					def lowerCamelCase_	(		self							:	Optional[Any]		):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE				:							Any						=	copy.deepcopy(self.__dict__		)
							SCREAMING_SNAKE_CASE				:							Optional[Any]						=	self.decoder.to_dict()
							SCREAMING_SNAKE_CASE				:							int						=	self.__class__.model_type
							return output










'''simple docstring'''




import unittest
from pathlib import Path

from transformers import is_vision_available, load_tool
from transformers.testing_utils import get_tests_dir

from .test_tools_common import ToolTesterMixin


if is_vision_available():
							from PIL import Image




class       UpperCamelCase__			(			unittest.TestCase		,			lowercase_	):




					"""simple docstring"""


					def lowerCamelCase_	(		self							:	Any		):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE				:							int						=	load_tool("""image-captioning"""		)
							self.tool.setup()
							SCREAMING_SNAKE_CASE				:							str						=	load_tool("""image-captioning"""     ,		remote=lowerCamelCase_		)


					def lowerCamelCase_	(		self							:	List[Any]		):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE				:							Union[str, Any]						=	Image.open(Path(get_tests_dir("""fixtures/tests_samples/COCO"""		)		) / """000000039769.png"""		)
							SCREAMING_SNAKE_CASE				:							Optional[int]						=	self.tool(lowerCamelCase_		)
							self.assertEqual(lowerCamelCase_     ,		"""two cats sleeping on a couch"""		)


					def lowerCamelCase_	(		self							:	str		):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE				:							Optional[Any]						=	Image.open(Path(get_tests_dir("""fixtures/tests_samples/COCO"""		)		) / """000000039769.png"""		)
							SCREAMING_SNAKE_CASE				:							Union[str, Any]						=	self.remote_tool(lowerCamelCase_		)
							self.assertEqual(lowerCamelCase_     ,		"""two cats sleeping on a couch"""		)


					def lowerCamelCase_	(		self							:	List[Any]		):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE				:							Union[str, Any]						=	Image.open(Path(get_tests_dir("""fixtures/tests_samples/COCO"""		)		) / """000000039769.png"""		)
							SCREAMING_SNAKE_CASE				:							str						=	self.tool(image=lowerCamelCase_		)
							self.assertEqual(lowerCamelCase_     ,		"""two cats sleeping on a couch"""		)



					def lowerCamelCase_	(		self							:	Any		):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE				:							Union[str, Any]						=	Image.open(Path(get_tests_dir("""fixtures/tests_samples/COCO"""		)		) / """000000039769.png"""		)
							SCREAMING_SNAKE_CASE				:							Optional[Any]						=	self.remote_tool(image=lowerCamelCase_		)
							self.assertEqual(lowerCamelCase_     ,		"""two cats sleeping on a couch"""		)



