

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


UpperCAmelCase__ :     Optional[int]				    =	logging.get_logger(__name__)







class        a__       (   UpperCAmelCase       ):







  """simple docstring"""




  UpperCAmelCase__      : Dict			       =["""pixel_values"""]


  def __init__(			self    : Union[str, Any]				,				UpperCAmelCase__    : bool = True				,				UpperCAmelCase__    : int = 3_2				,				UpperCAmelCase__    : Tuple=PILImageResampling.BILINEAR				,				UpperCAmelCase__    : bool = True				,				**UpperCAmelCase__    : Optional[Any]				,				)					->None:
        """simple docstring"""







        SCREAMING_SNAKE_CASE :      int       =   do_resize
        SCREAMING_SNAKE_CASE :      List[Any]       =   do_rescale
        SCREAMING_SNAKE_CASE :      List[str]       =   size_divisor
        SCREAMING_SNAKE_CASE :      Any       =   resample
        super().__init__(**UpperCAmelCase__		)


  def  _lowercase      (			self    : Any				,				UpperCAmelCase__    : np.ndarray				,				UpperCAmelCase__    : int				,				UpperCAmelCase__    : List[str]				,				UpperCAmelCase__    : Optional[ChannelDimension] = None				,				**UpperCAmelCase__    : Optional[int]		)					->np.ndarray:
        """simple docstring"""







        SCREAMING_SNAKE_CASE :      int       =   get_image_size(UpperCAmelCase__		)
        # Rounds the height and width down to the closest multiple of size_divisor
        SCREAMING_SNAKE_CASE :      Any       =   height // size_divisor * size_divisor
        SCREAMING_SNAKE_CASE :      Optional[int]       =   width // size_divisor * size_divisor
        SCREAMING_SNAKE_CASE :      Dict       =   resize(UpperCAmelCase__				,				(new_h, new_w)				,				resample=UpperCAmelCase__				,				data_format=UpperCAmelCase__				,				**UpperCAmelCase__		)
        return image


  def  _lowercase      (			self    : Any				,				UpperCAmelCase__    : np.ndarray				,				UpperCAmelCase__    : float				,				UpperCAmelCase__    : Optional[ChannelDimension] = None				,				**UpperCAmelCase__    : List[Any]		)					->np.ndarray:
        """simple docstring"""







        return rescale(image=UpperCAmelCase__				,				scale=UpperCAmelCase__				,				data_format=UpperCAmelCase__				,				**UpperCAmelCase__		)




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







        SCREAMING_SNAKE_CASE :      Union[str, Any]       =   do_resize if do_resize is not None else self.do_resize
        SCREAMING_SNAKE_CASE :      List[Any]       =   do_rescale if do_rescale is not None else self.do_rescale
        SCREAMING_SNAKE_CASE :      str       =   size_divisor if size_divisor is not None else self.size_divisor
        SCREAMING_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"""		)

        SCREAMING_SNAKE_CASE :      int       =   make_list_of_images(UpperCAmelCase__		)

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

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

        if do_resize:
              SCREAMING_SNAKE_CASE :      Optional[int]       =   [self.resize(UpperCAmelCase__				,				size_divisor=UpperCAmelCase__				,				resample=UpperCAmelCase__		) for image in images]

        if do_rescale:
              SCREAMING_SNAKE_CASE :      int       =   [self.rescale(UpperCAmelCase__				,				scale=1 / 2_5_5		) for image in images]

        SCREAMING_SNAKE_CASE :      List[str]       =   [to_channel_dimension_format(UpperCAmelCase__				,				UpperCAmelCase__		) for image in images]

        SCREAMING_SNAKE_CASE :      int       =   {"""pixel_values""": images}
        return BatchFeature(data=UpperCAmelCase__				,				tensor_type=UpperCAmelCase__		)







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


UpperCAmelCase__ :     Dict				    =    logging.get_logger(__name__)

UpperCAmelCase__ :     int				    =    {
    """abeja/gpt-neox-japanese-2.7b""": """https://huggingface.co/abeja/gpt-neox-japanese-2.7b/resolve/main/config.json""",
}







class        a__       (   UpperCAmelCase       ):







  """simple docstring"""




  UpperCAmelCase__      : Any			       ="""gpt_neox_japanese"""


  def __init__(			self    : Any				,				UpperCAmelCase__    : Any=3_2_0_0_0				,				UpperCAmelCase__    : Dict=2_5_6_0				,				UpperCAmelCase__    : List[str]=3_2				,				UpperCAmelCase__    : Optional[int]=3_2				,				UpperCAmelCase__    : List[str]=4				,				UpperCAmelCase__    : List[str]="gelu"				,				UpperCAmelCase__    : Optional[int]=1.00				,				UpperCAmelCase__    : List[Any]=1_0_0_0_0				,				UpperCAmelCase__    : Tuple=2_0_4_8				,				UpperCAmelCase__    : Optional[int]=0.02				,				UpperCAmelCase__    : Dict=1e-5				,				UpperCAmelCase__    : Dict=True				,				UpperCAmelCase__    : Tuple=3_1_9_9_6				,				UpperCAmelCase__    : Tuple=3_1_9_9_9				,				UpperCAmelCase__    : Dict=0.1				,				UpperCAmelCase__    : Union[str, Any]=0.0				,				**UpperCAmelCase__    : Optional[Any]				,				)					->Optional[Any]:
        """simple docstring"""







        super().__init__(bos_token_id=UpperCAmelCase__				,				eos_token_id=UpperCAmelCase__				,				**UpperCAmelCase__		)
        SCREAMING_SNAKE_CASE :      List[str]       =   vocab_size
        SCREAMING_SNAKE_CASE :      List[str]       =   max_position_embeddings
        SCREAMING_SNAKE_CASE :      Tuple       =   hidden_size
        SCREAMING_SNAKE_CASE :      Union[str, Any]       =   num_hidden_layers
        SCREAMING_SNAKE_CASE :      Optional[int]       =   num_attention_heads
        SCREAMING_SNAKE_CASE :      Any       =   intermediate_multiple_size
        SCREAMING_SNAKE_CASE :      Tuple       =   hidden_act
        SCREAMING_SNAKE_CASE :      Any       =   rotary_pct
        SCREAMING_SNAKE_CASE :      Tuple       =   rotary_emb_base
        SCREAMING_SNAKE_CASE :      Union[str, Any]       =   initializer_range
        SCREAMING_SNAKE_CASE :      Optional[Any]       =   layer_norm_eps
        SCREAMING_SNAKE_CASE :      str       =   use_cache
        SCREAMING_SNAKE_CASE :      Any       =   attention_dropout
        SCREAMING_SNAKE_CASE :      str       =   hidden_dropout




