




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


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

snake_case_ : int    		=       {
    "transfo-xl-wt103": "https://huggingface.co/transfo-xl-wt103/resolve/main/config.json",
}







class __snake_case			(			a		):
   UpperCAmelCase__  :    Optional[int]          =  '''transfo-xl'''
   UpperCAmelCase__  :    Optional[Any]          =  ['''mems''']
   UpperCAmelCase__  :    Optional[Any]          =  {
       '''n_token''': '''vocab_size''',
       '''hidden_size''': '''d_model''',
       '''num_attention_heads''': '''n_head''',
       '''num_hidden_layers''': '''n_layer''',
   }







   def __init__(      self		:						List[str]					,						_snake_case		:						Union[str, Any]=267735					,						_snake_case		:						str=[20000, 40000, 200000]					,						_snake_case		:						List[Any]=1024					,						_snake_case		:						Any=1024					,						_snake_case		:						Optional[Any]=16					,						_snake_case		:						Tuple=64					,						_snake_case		:						Dict=4096					,						_snake_case		:						Optional[int]=4					,						_snake_case		:						Optional[int]=False					,						_snake_case		:						Optional[int]=18					,						_snake_case		:						List[str]=1600					,						_snake_case		:						Any=1000					,						_snake_case		:						Tuple=True					,						_snake_case		:						Optional[Any]=True					,						_snake_case		:						Optional[Any]=0					,						_snake_case		:						List[str]=-1					,						_snake_case		:						str=True					,						_snake_case		:						List[Any]=0.1					,						_snake_case		:						int=0.0					,						_snake_case		:						Optional[int]=True					,						_snake_case		:						Optional[int]="normal"					,						_snake_case		:						Optional[Any]=0.0_1					,						_snake_case		:						Tuple=0.0_1					,						_snake_case		:						Tuple=0.0_2					,						_snake_case		:						Optional[int]=1e-5					,						_snake_case		:						Union[str, Any]=0					,						**_snake_case		:						Optional[Any]					,						):

        """simple docstring"""


        UpperCAmelCase_          =							vocab_size
        UpperCAmelCase_          =							[]
        self.cutoffs.extend(_snake_case)
        if proj_share_all_but_first:
             UpperCAmelCase_          =							[False] + [True] * len(self.cutoffs)
        else:
             UpperCAmelCase_          =							[False] + [False] * len(self.cutoffs)
        UpperCAmelCase_          =							d_model
        UpperCAmelCase_          =							d_embed
        UpperCAmelCase_          =							d_head
        UpperCAmelCase_          =							d_inner
        UpperCAmelCase_          =							div_val
        UpperCAmelCase_          =							pre_lnorm
        UpperCAmelCase_          =							n_layer
        UpperCAmelCase_          =							n_head
        UpperCAmelCase_          =							mem_len
        UpperCAmelCase_          =							same_length
        UpperCAmelCase_          =							attn_type
        UpperCAmelCase_          =							clamp_len
        UpperCAmelCase_          =							sample_softmax
        UpperCAmelCase_          =							adaptive
        UpperCAmelCase_          =							dropout
        UpperCAmelCase_          =							dropatt
        UpperCAmelCase_          =							untie_r
        UpperCAmelCase_          =							init
        UpperCAmelCase_          =							init_range
        UpperCAmelCase_          =							proj_init_std
        UpperCAmelCase_          =							init_std
        UpperCAmelCase_          =							layer_norm_epsilon
        super().__init__(eos_token_id=_snake_case					,						**_snake_case)







   @property
   def lowerCamelCase						(      self		:						Optional[int]):

        """simple docstring"""


        logger.info(F"""The model {self.model_type} is one of the few models that has no sequence length limit.""")
        return -1







   @max_position_embeddings.setter
   def lowerCamelCase						(      self		:						Union[str, Any]					,						_snake_case		:						Dict):

        """simple docstring"""


        raise NotImplementedError(
            F"""The model {self.model_type} is one of the few models that has no sequence length limit.""")







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


__lowercase							 =					logging.get_logger(__name__)


class 	lowerCamelCase_     (   UpperCAmelCase_ ):






    '''simple docstring'''






    a__	:						Optional[Any]						=      ["""pixel_values"""]







    def __init__(	self , __lowercase = True , __lowercase = 32 , __lowercase=PILImageResampling.BILINEAR , __lowercase = True , **__lowercase , )       ->	None:
        __UpperCamelCase     :Optional[int]			  =		do_resize
        __UpperCamelCase     :Any			  =		do_rescale
        __UpperCamelCase     :str			  =		size_divisor
        __UpperCamelCase     :Dict			  =		resample
        super().__init__(**__lowercase)







    def 			UpperCamelCase__   (	self , __lowercase , __lowercase , __lowercase , __lowercase = None , **__lowercase)       ->	np.ndarray:
        __UpperCamelCase  ,       __UpperCamelCase     :int			  =		get_image_size(__lowercase)
        # Rounds the height and width down to the closest multiple of size_divisor
        __UpperCamelCase     :List[Any]			  =		height // size_divisor * size_divisor
        __UpperCamelCase     :List[str]			  =		width // size_divisor * size_divisor
        __UpperCamelCase     :str			  =		resize(__lowercase , (new_h, new_w) , resample=__lowercase , data_format=__lowercase , **__lowercase)
        return image







    def 			UpperCamelCase__   (	self , __lowercase , __lowercase , __lowercase = None , **__lowercase)       ->	np.ndarray:
        return rescale(image=__lowercase , scale=__lowercase , data_format=__lowercase , **__lowercase)







    def 			UpperCamelCase__   (	self , __lowercase , __lowercase = None , __lowercase = None , __lowercase=None , __lowercase = None , __lowercase = None , __lowercase = ChannelDimension.FIRST , **__lowercase , )       ->	BatchFeature:
        __UpperCamelCase     :Union[str, Any]			  =		do_resize if do_resize is not None else self.do_resize
        __UpperCamelCase     :Tuple			  =		do_rescale if do_rescale is not None else self.do_rescale
        __UpperCamelCase     :List[str]			  =		size_divisor if size_divisor is not None else self.size_divisor
        __UpperCamelCase     :List[Any]			  =		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     :List[Any]			  =		make_list_of_images(__lowercase)

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

        # All transformations expect numpy arrays.
        __UpperCamelCase     :Optional[Any]			  =		[to_numpy_array(__lowercase) for img in images]

        if do_resize:
            __UpperCamelCase     :List[str]			  =		[self.resize(__lowercase , size_divisor=__lowercase , resample=__lowercase) for image in images]

        if do_rescale:
            __UpperCamelCase     :Dict			  =		[self.rescale(__lowercase , scale=1 / 255) for image in images]

        __UpperCamelCase     :str			  =		[to_channel_dimension_format(__lowercase , __lowercase) for image in images]

        __UpperCamelCase     :int			  =		{'''pixel_values''': images}
        return BatchFeature(data=__lowercase , tensor_type=__lowercase)





