






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


__UpperCAmelCase      				=		logging.get_logger(__name__)

__UpperCAmelCase      				=		{
    """facebook/nllb-moe-54B""": """https://huggingface.co/facebook/nllb-moe-54b/resolve/main/config.json""",
}



class     lowerCamelCase (lowercase_     ):







		'''simple docstring'''



		_snake_case       :       Tuple					=    '''nllb-moe'''
		_snake_case       :       Dict					=    ['''past_key_values''']
		_snake_case       :       Optional[int]					=    {'''num_attention_heads''': '''encoder_attention_heads''', '''hidden_size''': '''d_model'''}



		def __init__(				self							,						_UpperCamelCase=1_2_8_1_1_2							,						_UpperCamelCase=1_0_2_4							,						_UpperCamelCase=1_2							,						_UpperCamelCase=4_0_9_6							,						_UpperCamelCase=1_6							,						_UpperCamelCase=1_2							,						_UpperCamelCase=4_0_9_6							,						_UpperCamelCase=1_6							,						_UpperCamelCase=0.05							,						_UpperCamelCase=0.05							,						_UpperCamelCase=True							,						_UpperCamelCase=True							,						_UpperCamelCase="relu"							,						_UpperCamelCase=1_0_2_4							,						_UpperCamelCase=0.1							,						_UpperCamelCase=0.1							,						_UpperCamelCase=0.0							,						_UpperCamelCase=0.02							,						_UpperCamelCase=2							,						_UpperCamelCase=True							,						_UpperCamelCase=False							,						_UpperCamelCase="float32"							,						_UpperCamelCase=False							,						_UpperCamelCase=1_2_8							,						_UpperCamelCase=6_4							,						_UpperCamelCase=4							,						_UpperCamelCase=4							,						_UpperCamelCase=0.0_01							,						_UpperCamelCase=0.0_01							,						_UpperCamelCase="all"							,						_UpperCamelCase=False							,						_UpperCamelCase=False							,						_UpperCamelCase=1.0							,						_UpperCamelCase=0.2							,						_UpperCamelCase=1							,						_UpperCamelCase=0							,						_UpperCamelCase=2							,						_UpperCamelCase=False							,						**_UpperCamelCase							,						)      ->				Union[str, Any]:
							UpperCAmelCase_       : int				=		vocab_size
							UpperCAmelCase_       : Optional[int]				=		max_position_embeddings
							UpperCAmelCase_       : List[Any]				=		d_model
							UpperCAmelCase_       : Optional[Any]				=		encoder_ffn_dim
							UpperCAmelCase_       : Any				=		encoder_layers
							UpperCAmelCase_       : Dict				=		encoder_attention_heads
							UpperCAmelCase_       : Optional[Any]				=		decoder_ffn_dim
							UpperCAmelCase_       : Tuple				=		decoder_layers
							UpperCAmelCase_       : int				=		decoder_attention_heads
							UpperCAmelCase_       : int				=		dropout
							UpperCAmelCase_       : List[Any]				=		attention_dropout
							UpperCAmelCase_       : str				=		activation_dropout
							UpperCAmelCase_       : Union[str, Any]				=		activation_function
							UpperCAmelCase_       : Any				=		init_std
							UpperCAmelCase_       : Any				=		encoder_layerdrop
							UpperCAmelCase_       : str				=		decoder_layerdrop
							UpperCAmelCase_       : List[str]				=		use_cache
							UpperCAmelCase_       : Optional[Any]				=		encoder_layers
							UpperCAmelCase_       : List[str]				=		scale_embedding  # scale factor will be sqrt(d_model) if True
							UpperCAmelCase_       : str				=		router_z_loss_coef
							UpperCAmelCase_       : Dict				=		router_aux_loss_coef
							UpperCAmelCase_       : Tuple				=		decoder_sparse_step
							UpperCAmelCase_       : str				=		encoder_sparse_step
							UpperCAmelCase_       : List[str]				=		num_experts
							UpperCAmelCase_       : Union[str, Any]				=		expert_capacity
							UpperCAmelCase_       : List[Any]				=		router_bias
							if router_dtype not in ["float32", "float16", "bfloat16"]:
												raise ValueError(f"`router_dtype` must be one of \'float32\', \'float16\' or \'bfloat16\', got {router_dtype}"  )
							UpperCAmelCase_       : Optional[int]				=		router_dtype

							UpperCAmelCase_       : Optional[Any]				=		router_ignore_padding_tokens
							UpperCAmelCase_       : Optional[int]				=		batch_prioritized_routing
							UpperCAmelCase_       : List[str]				=		second_expert_policy
							UpperCAmelCase_       : Optional[Any]				=		normalize_router_prob_before_dropping
							UpperCAmelCase_       : Dict				=		moe_eval_capacity_token_fraction
							UpperCAmelCase_       : Dict				=		moe_token_dropout
							UpperCAmelCase_       : Optional[int]				=		output_router_logits
							super().__init__(
							    pad_token_id=_UpperCamelCase							,						bos_token_id=_UpperCamelCase							,						eos_token_id=_UpperCamelCase							,						is_encoder_decoder=_UpperCamelCase							,						decoder_start_token_id=_UpperCamelCase							,						**_UpperCamelCase							,						)









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







class 					lowercase							(			lowercase_     ):
				__SCREAMING_SNAKE_CASE   :					Union[str, Any]			     =     ['''image_processor''', '''tokenizer''']
				__SCREAMING_SNAKE_CASE   :					Tuple			     =     '''AutoImageProcessor'''
				__SCREAMING_SNAKE_CASE   :					Dict			     =     '''AutoTokenizer'''




				def __init__(   self ,  snake_case ,  snake_case			):
											super().__init__(snake_case ,  snake_case			)
											snake_case_     							=       self.image_processor




				def __call__(   self ,  snake_case=None ,  snake_case=None ,  snake_case=None ,  **snake_case			):

											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:
																		snake_case_     							=       self.tokenizer(snake_case ,  return_tensors=snake_case ,  **snake_case			)

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

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




				def        a				(   self ,  *snake_case ,  **snake_case			):
											return self.tokenizer.batch_decode(*snake_case ,  **snake_case			)




				def        a				(   self ,  *snake_case ,  **snake_case			):
											return self.tokenizer.decode(*snake_case ,  **snake_case			)




				@property
				def        a				(   self			):
											return ["input_ids", "attention_mask", "pixel_values"]




