





'''simple docstring'''







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


snake_case_     :       Any						=  logging.get_logger(__name__)

snake_case_     :       Optional[int]						=  {
    "facebook/nllb-moe-54B": "https://huggingface.co/facebook/nllb-moe-54b/resolve/main/config.json",
}


class 					__a      (lowerCamelCase     ):
							__a					:   str									=       "nllb-moe"
							__a					:   List[Any]									=       ["past_key_values"]
							__a					:   int									=       {"num_attention_heads": "encoder_attention_heads", "hidden_size": "d_model"}

							def __init__(							self							:     Any       ,     __magic_name__							:     Dict=12_81_12       ,     __magic_name__							:     List[str]=10_24       ,     __magic_name__							:     Optional[Any]=12       ,     __magic_name__							:     str=40_96       ,     __magic_name__							:     List[str]=16       ,     __magic_name__							:     Optional[int]=12       ,     __magic_name__							:     str=40_96       ,     __magic_name__							:     Optional[Any]=16       ,     __magic_name__							:     Optional[Any]=0.0_5       ,     __magic_name__							:     Optional[int]=0.0_5       ,     __magic_name__							:     Optional[int]=True       ,     __magic_name__							:     Union[str, Any]=True       ,     __magic_name__							:     Optional[int]="relu"       ,     __magic_name__							:     Dict=10_24       ,     __magic_name__							:     Tuple=0.1       ,     __magic_name__							:     Optional[Any]=0.1       ,     __magic_name__							:     Optional[int]=0.0       ,     __magic_name__							:     Tuple=0.0_2       ,     __magic_name__							:     Dict=2       ,     __magic_name__							:     Any=True       ,     __magic_name__							:     List[Any]=False       ,     __magic_name__							:     Dict="float32"       ,     __magic_name__							:     str=False       ,     __magic_name__							:     int=1_28       ,     __magic_name__							:     Optional[int]=64       ,     __magic_name__							:     str=4       ,     __magic_name__							:     Optional[Any]=4       ,     __magic_name__							:     List[str]=0.0_0_1       ,     __magic_name__							:     Dict=0.0_0_1       ,     __magic_name__							:     Tuple="all"       ,     __magic_name__							:     Any=False       ,     __magic_name__							:     Any=False       ,     __magic_name__							:     Union[str, Any]=1.0       ,     __magic_name__							:     List[str]=0.2       ,     __magic_name__							:     str=1       ,     __magic_name__							:     int=0       ,     __magic_name__							:     int=2       ,     __magic_name__							:     Dict=False       ,     **__magic_name__							:     int       ,     )					->       int:







													"""simple docstring"""
													UpperCAmelCase_			:      Dict     						=  vocab_size
													UpperCAmelCase_			:      int     						=  max_position_embeddings
													UpperCAmelCase_			:      int     						=  d_model
													UpperCAmelCase_			:      Dict     						=  encoder_ffn_dim
													UpperCAmelCase_			:      str     						=  encoder_layers
													UpperCAmelCase_			:      Union[str, Any]     						=  encoder_attention_heads
													UpperCAmelCase_			:      int     						=  decoder_ffn_dim
													UpperCAmelCase_			:      str     						=  decoder_layers
													UpperCAmelCase_			:      Dict     						=  decoder_attention_heads
													UpperCAmelCase_			:      Any     						=  dropout
													UpperCAmelCase_			:      Tuple     						=  attention_dropout
													UpperCAmelCase_			:      Dict     						=  activation_dropout
													UpperCAmelCase_			:      str     						=  activation_function
													UpperCAmelCase_			:      Union[str, Any]     						=  init_std
													UpperCAmelCase_			:      Union[str, Any]     						=  encoder_layerdrop
													UpperCAmelCase_			:      List[Any]     						=  decoder_layerdrop
													UpperCAmelCase_			:      str     						=  use_cache
													UpperCAmelCase_			:      int     						=  encoder_layers
													UpperCAmelCase_			:      Optional[Any]     						=  scale_embedding  # scale factor will be sqrt(d_model) if True
													UpperCAmelCase_			:      List[str]     						=  router_z_loss_coef
													UpperCAmelCase_			:      Optional[Any]     						=  router_aux_loss_coef
													UpperCAmelCase_			:      str     						=  decoder_sparse_step
													UpperCAmelCase_			:      int     						=  encoder_sparse_step
													UpperCAmelCase_			:      int     						=  num_experts
													UpperCAmelCase_			:      Optional[int]     						=  expert_capacity
													UpperCAmelCase_			:      Union[str, 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_			:      List[str]     						=  router_dtype

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












'''simple docstring'''







from typing import List, Optional, Union

import numpy as np
import PIL.Image

from ...image_processing_utils import BaseImageProcessor, BatchFeature
from ...image_transforms import rescale, resize, to_channel_dimension_format
from ...image_utils import (
    ChannelDimension,
    PILImageResampling,
    get_image_size,
    make_list_of_images,
    to_numpy_array,
    valid_images,
)
from ...utils import TensorType, logging


snake_case_     :       Union[str, Any]						=  logging.get_logger(__name__)


class 					__a      (lowerCamelCase     ):
							__a					:   Tuple									=       ["pixel_values"]

							def __init__(							self							:     List[Any]       ,     __magic_name__							:     bool = True       ,     __magic_name__							:     int = 32       ,     __magic_name__							:     Union[str, Any]=PILImageResampling.BILINEAR       ,     __magic_name__							:     bool = True       ,     **__magic_name__							:     List[str]       ,     )					->       None:







													"""simple docstring"""
													UpperCAmelCase_			:      int     						=  do_resize
													UpperCAmelCase_			:      Tuple     						=  do_rescale
													UpperCAmelCase_			:      List[Any]     						=  size_divisor
													UpperCAmelCase_			:      Any     						=  resample
													super().__init__(**__magic_name__   )

							def     UpperCAmelCase__	(							self							:     Optional[Any]       ,     __magic_name__							:     np.ndarray       ,     __magic_name__							:     int       ,     __magic_name__							:     str       ,     __magic_name__							:     Optional[ChannelDimension] = None       ,     **__magic_name__							:     Tuple   )					->       np.ndarray:







													"""simple docstring"""
													UpperCAmelCase_						,       UpperCAmelCase_			:      List[str]     						=  get_image_size(__magic_name__   )
													# Rounds the height and width down to the closest multiple of size_divisor
													UpperCAmelCase_			:      Dict     						=  height // size_divisor * size_divisor
													UpperCAmelCase_			:      Dict     						=  width // size_divisor * size_divisor
													UpperCAmelCase_			:      Any     						=  resize(__magic_name__       ,     (new_h, new_w)       ,     resample=__magic_name__       ,     data_format=__magic_name__       ,     **__magic_name__   )
													return image

							def     UpperCAmelCase__	(							self							:     int       ,     __magic_name__							:     np.ndarray       ,     __magic_name__							:     float       ,     __magic_name__							:     Optional[ChannelDimension] = None       ,     **__magic_name__							:     Optional[Any]   )					->       np.ndarray:







													"""simple docstring"""
													return rescale(image=__magic_name__       ,     scale=__magic_name__       ,     data_format=__magic_name__       ,     **__magic_name__   )



							def     UpperCAmelCase__	(							self							:     str       ,     __magic_name__							:     Union["PIL.Image.Image", TensorType, List["PIL.Image.Image"], List[TensorType]]       ,     __magic_name__							:     Optional[bool] = None       ,     __magic_name__							:     Optional[int] = None       ,     __magic_name__							:     Any=None       ,     __magic_name__							:     Optional[bool] = None       ,     __magic_name__							:     Optional[Union[TensorType, str]] = None       ,     __magic_name__							:     ChannelDimension = ChannelDimension.FIRST       ,     **__magic_name__							:     Tuple       ,     )					->       BatchFeature:







													"""simple docstring"""
													UpperCAmelCase_			:      Dict     						=  do_resize if do_resize is not None else self.do_resize
													UpperCAmelCase_			:      str     						=  do_rescale if do_rescale is not None else self.do_rescale
													UpperCAmelCase_			:      Any     						=  size_divisor if size_divisor is not None else self.size_divisor
													UpperCAmelCase_			:      Dict     						=  resample if resample is not None else self.resample

													if do_resize and size_divisor is None:
																			raise ValueError('''size_divisor is required for resizing'''   )

													UpperCAmelCase_			:      Optional[int]     						=  make_list_of_images(__magic_name__   )

													if not valid_images(__magic_name__   ):
																			raise ValueError('''Invalid image(s)'''   )

													# All transformations expect numpy arrays.
													UpperCAmelCase_			:      List[str]     						=  [to_numpy_array(__magic_name__   ) for img in images]

													if do_resize:
																			UpperCAmelCase_			:      str     						=  [self.resize(__magic_name__       ,     size_divisor=__magic_name__       ,     resample=__magic_name__   ) for image in images]

													if do_rescale:
																			UpperCAmelCase_			:      Tuple     						=  [self.rescale(__magic_name__       ,     scale=1 / 2_55   ) for image in images]

													UpperCAmelCase_			:      Union[str, Any]     						=  [to_channel_dimension_format(__magic_name__       ,     __magic_name__   ) for image in images]

													UpperCAmelCase_			:      int     						=  {'''pixel_values''': images}
													return BatchFeature(data=__magic_name__       ,     tensor_type=__magic_name__   )





