






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


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

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







class  _lowercase   (   _A						):
      _a							:						Dict										=							'nllb-moe'
      _a							:						str										=							['past_key_values']
      _a							:						str										=							{'num_attention_heads': 'encoder_attention_heads', 'hidden_size': 'd_model'}
      def __init__(     self				,			a=1_2_8_1_1_2				,			a=1_0_2_4				,			a=1_2				,			a=4_0_9_6				,			a=1_6				,			a=1_2				,			a=4_0_9_6				,			a=1_6				,			a=0.05				,			a=0.05				,			a=True				,			a=True				,			a="relu"				,			a=1_0_2_4				,			a=0.1				,			a=0.1				,			a=0.0				,			a=0.02				,			a=2				,			a=True				,			a=False				,			a="float32"				,			a=False				,			a=1_2_8				,			a=6_4				,			a=4				,			a=4				,			a=0.001				,			a=0.001				,			a="all"				,			a=False				,			a=False				,			a=1.0				,			a=0.2				,			a=1				,			a=0				,			a=2				,			a=False				,			**a				,			):
       snake_case__  :    Dict							       =vocab_size
       snake_case__  :    Dict							       =max_position_embeddings
       snake_case__  :    Optional[Any]							       =d_model
       snake_case__  :    Any							       =encoder_ffn_dim
       snake_case__  :    Optional[int]							       =encoder_layers
       snake_case__  :    str							       =encoder_attention_heads
       snake_case__  :    Optional[int]							       =decoder_ffn_dim
       snake_case__  :    Dict							       =decoder_layers
       snake_case__  :    Tuple							       =decoder_attention_heads
       snake_case__  :    Any							       =dropout
       snake_case__  :    str							       =attention_dropout
       snake_case__  :    Optional[Any]							       =activation_dropout
       snake_case__  :    Optional[int]							       =activation_function
       snake_case__  :    Optional[Any]							       =init_std
       snake_case__  :    Any							       =encoder_layerdrop
       snake_case__  :    Tuple							       =decoder_layerdrop
       snake_case__  :    List[str]							       =use_cache
       snake_case__  :    List[str]							       =encoder_layers
       snake_case__  :    Dict							       =scale_embedding  # scale factor will be sqrt(d_model) if True
       snake_case__  :    int							       =router_z_loss_coef
       snake_case__  :    Tuple							       =router_aux_loss_coef
       snake_case__  :    int							       =decoder_sparse_step
       snake_case__  :    Optional[Any]							       =encoder_sparse_step
       snake_case__  :    Tuple							       =num_experts
       snake_case__  :    List[Any]							       =expert_capacity
       snake_case__  :    Tuple							       =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}"   )
       snake_case__  :    Optional[Any]							       =router_dtype

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













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


__lowerCamelCase	:		Tuple										=   logging.get_logger(__name__)







class  _lowercase   (   _A						):
      _a							:						Optional[int]										=							['pixel_values']
      def __init__(     self				,			a = True				,			a = 3_2				,			a=PILImageResampling.BILINEAR				,			a = True				,			**a				,			):
       snake_case__  :    Any							       =do_resize
       snake_case__  :    Optional[int]							       =do_rescale
       snake_case__  :    Optional[Any]							       =size_divisor
       snake_case__  :    Optional[int]							       =resample
       super().__init__(**a   )
      def 						lowercase__					(     self				,			a				,			a				,			a				,			a = None				,			**a   ):
       snake_case__       ,   snake_case__  :    List[str]							       =get_image_size(a   )
       # Rounds the height and width down to the closest multiple of size_divisor
       snake_case__  :    str							       =height // size_divisor * size_divisor
       snake_case__  :    List[str]							       =width // size_divisor * size_divisor
       snake_case__  :    int							       =resize(a				,			(new_h, new_w)				,			resample=a				,			data_format=a				,			**a   )
       return image
      def 						lowercase__					(     self				,			a				,			a				,			a = None				,			**a   ):
       return rescale(image=a				,			scale=a				,			data_format=a				,			**a   )



      def 						lowercase__					(     self				,			a				,			a = None				,			a = None				,			a=None				,			a = None				,			a = None				,			a = ChannelDimension.FIRST				,			**a				,			):
       snake_case__  :    Optional[Any]							       =do_resize if do_resize is not None else self.do_resize
       snake_case__  :    str							       =do_rescale if do_rescale is not None else self.do_rescale
       snake_case__  :    List[Any]							       =size_divisor if size_divisor is not None else self.size_divisor
       snake_case__  :    Optional[int]							       =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"""   )

       snake_case__  :    Optional[int]							       =make_list_of_images(a   )

       if not valid_images(a   ):
        raise ValueError("""Invalid image(s)"""   )

       # All transformations expect numpy arrays.
       snake_case__  :    str							       =[to_numpy_array(a   ) for img in images]

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

       if do_rescale:
        snake_case__  :    Union[str, Any]							       =[self.rescale(a				,			scale=1 / 2_5_5   ) for image in images]

       snake_case__  :    int							       =[to_channel_dimension_format(a				,			a   ) for image in images]

       snake_case__  :    Tuple							       ={"""pixel_values""": images}
       return BatchFeature(data=a				,			tensor_type=a   )





