



from typing import Dict, List, Optional, Union

import numpy as np

from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict
from ...image_transforms import (
    center_crop,
    get_resize_output_image_size,
    normalize,
    rescale,
    resize,
    to_channel_dimension_format,
)
from ...image_utils import (
    IMAGENET_STANDARD_MEAN,
    IMAGENET_STANDARD_STD,
    ChannelDimension,
    ImageInput,
    PILImageResampling,
    make_list_of_images,
    to_numpy_array,
    valid_images,
)
from ...utils import TensorType, logging


A__  :  Tuple								=					logging.get_logger(__name__)



class 				__snake_case						(     UpperCamelCase_						):
							_a			      = ['''pixel_values''']




							def __init__(       self     :       Any				,				A_     :       bool = True				,				A_     :       Optional[Dict[str, int]] = None				,				A_     :       PILImageResampling = PILImageResampling.BILINEAR				,				A_     :       bool = True				,				A_     :       Dict[str, int] = None				,				A_     :       bool = True				,				A_     :       Union[int, float] = 1 / 2_5_5				,				A_     :       bool = True				,				A_     :       Optional[Union[float, List[float]]] = None				,				A_     :       Optional[Union[float, List[float]]] = None				,				**A_     :       Optional[Any]				,				):
									super().__init__(**A_)
									lowerCAmelCase_			:     Optional[Any]									= size if size is not None else {'''shortest_edge''': 2_5_6}
									lowerCAmelCase_			:     int									= get_size_dict(A_				,				default_to_square=A_)
									lowerCAmelCase_			:     Dict									= crop_size if crop_size is not None else {'''height''': 2_2_4, '''width''': 2_2_4}
									lowerCAmelCase_			:     Tuple									= get_size_dict(A_)
									lowerCAmelCase_			:     Union[str, Any]									= do_resize
									lowerCAmelCase_			:     Tuple									= size
									lowerCAmelCase_			:     List[Any]									= resample
									lowerCAmelCase_			:     List[str]									= do_center_crop
									lowerCAmelCase_			:     Optional[int]									= crop_size
									lowerCAmelCase_			:     Optional[int]									= do_rescale
									lowerCAmelCase_			:     Any									= rescale_factor
									lowerCAmelCase_			:     str									= do_normalize
									lowerCAmelCase_			:     List[Any]									= image_mean if image_mean is not None else IMAGENET_STANDARD_MEAN
									lowerCAmelCase_			:     Optional[Any]									= image_std if image_std is not None else IMAGENET_STANDARD_STD




							def    UpperCAmelCase__			(       self     :       int				,				A_     :       np.ndarray				,				A_     :       Dict[str, int]				,				A_     :       PILImageResampling = PILImageResampling.BICUBIC				,				A_     :       Optional[Union[str, ChannelDimension]] = None				,				**A_     :       List[Any]				,				):
									lowerCAmelCase_			:     str									= get_size_dict(A_				,				default_to_square=A_)
									if "shortest_edge" not in size:
											raise ValueError(F"""The `size` parameter must contain the key `shortest_edge`. Got {size.keys()}""")
									lowerCAmelCase_			:     str									= get_resize_output_image_size(A_				,				size=size['''shortest_edge''']				,				default_to_square=A_)
									return resize(A_				,				size=A_				,				resample=A_				,				data_format=A_				,				**A_)




							def    UpperCAmelCase__			(       self     :       str				,				A_     :       np.ndarray				,				A_     :       Dict[str, int]				,				A_     :       Optional[Union[str, ChannelDimension]] = None				,				**A_     :       List[str]				,				):
									lowerCAmelCase_			:     Union[str, Any]									= get_size_dict(A_)
									return center_crop(A_				,				size=(size['''height'''], size['''width'''])				,				data_format=A_				,				**A_)




							def    UpperCAmelCase__			(       self     :       Union[str, Any]				,				A_     :       np.ndarray				,				A_     :       float				,				A_     :       Optional[Union[str, ChannelDimension]] = None				,				**A_     :       Tuple):
									return rescale(A_				,				scale=A_				,				data_format=A_				,				**A_)




							def    UpperCAmelCase__			(       self     :       Dict				,				A_     :       np.ndarray				,				A_     :       Union[float, List[float]]				,				A_     :       Union[float, List[float]]				,				A_     :       Optional[Union[str, ChannelDimension]] = None				,				**A_     :       str				,				):
									return normalize(A_				,				mean=A_				,				std=A_				,				data_format=A_				,				**A_)







							def    UpperCAmelCase__			(       self     :       Any				,				A_     :       ImageInput				,				A_     :       Optional[bool] = None				,				A_     :       Dict[str, int] = None				,				A_     :       PILImageResampling = None				,				A_     :       bool = None				,				A_     :       Dict[str, int] = None				,				A_     :       Optional[bool] = None				,				A_     :       Optional[float] = None				,				A_     :       Optional[bool] = None				,				A_     :       Optional[Union[float, List[float]]] = None				,				A_     :       Optional[Union[float, List[float]]] = None				,				A_     :       Optional[Union[str, TensorType]] = None				,				A_     :       Union[str, ChannelDimension] = ChannelDimension.FIRST				,				**A_     :       Dict				,				):
									lowerCAmelCase_			:     Optional[Any]									= do_resize if do_resize is not None else self.do_resize
									lowerCAmelCase_			:     Dict									= size if size is not None else self.size
									lowerCAmelCase_			:     List[str]									= get_size_dict(A_				,				default_to_square=A_)
									lowerCAmelCase_			:     Union[str, Any]									= resample if resample is not None else self.resample
									lowerCAmelCase_			:     Tuple									= do_center_crop if do_center_crop is not None else self.do_center_crop
									lowerCAmelCase_			:     Any									= crop_size if crop_size is not None else self.crop_size
									lowerCAmelCase_			:     int									= get_size_dict(A_)
									lowerCAmelCase_			:     Tuple									= do_rescale if do_rescale is not None else self.do_rescale
									lowerCAmelCase_			:     Optional[Any]									= rescale_factor if rescale_factor is not None else self.rescale_factor
									lowerCAmelCase_			:     Dict									= do_normalize if do_normalize is not None else self.do_normalize
									lowerCAmelCase_			:     Union[str, Any]									= image_mean if image_mean is not None else self.image_mean
									lowerCAmelCase_			:     List[str]									= image_std if image_std is not None else self.image_std

									lowerCAmelCase_			:     Dict									= make_list_of_images(A_)

									if not valid_images(A_):
											raise ValueError(
											    '''Invalid image type. Must be of type PIL.Image.Image, numpy.ndarray, '''
											    '''torch.Tensor, tf.Tensor or jax.ndarray.''')

									if do_resize and size is None:
											raise ValueError('''Size must be specified if do_resize is True.''')

									if do_center_crop and crop_size is None:
											raise ValueError('''Crop size must be specified if do_center_crop is True.''')

									if do_rescale and rescale_factor is None:
											raise ValueError('''Rescale factor must be specified if do_rescale is True.''')

									if do_normalize and (image_mean is None or image_std is None):
											raise ValueError('''Image mean and std must be specified if do_normalize is True.''')

									# All transformations expect numpy arrays.
									lowerCAmelCase_			:     Any									= [to_numpy_array(A_) for image in images]

									if do_resize:
											lowerCAmelCase_			:     Optional[Any]									= [self.resize(image=A_				,				size=A_				,				resample=A_) for image in images]

									if do_center_crop:
											lowerCAmelCase_			:     List[str]									= [self.center_crop(image=A_				,				size=A_) for image in images]

									if do_rescale:
											lowerCAmelCase_			:     Tuple									= [self.rescale(image=A_				,				scale=A_) for image in images]

									if do_normalize:
											lowerCAmelCase_			:     int									= [self.normalize(image=A_				,				mean=A_				,				std=A_) for image in images]

									lowerCAmelCase_			:     Optional[int]									= [to_channel_dimension_format(A_				,				A_) for image in images]

									lowerCAmelCase_			:     str									= {'''pixel_values''': images}
									return BatchFeature(data=A_				,				tensor_type=A_)










from collections import OrderedDict
from typing import Mapping

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


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

A__  :  Tuple								=					{
    '''facebook/xlm-roberta-xl''': '''https://huggingface.co/facebook/xlm-roberta-xl/resolve/main/config.json''',
    '''facebook/xlm-roberta-xxl''': '''https://huggingface.co/facebook/xlm-roberta-xxl/resolve/main/config.json''',
    # See all XLM-RoBERTa-XL models at https://huggingface.co/models?filter=xlm-roberta-xl
}



class 				__snake_case						(     UpperCamelCase_						):
							_a			      = '''xlm-roberta-xl'''




							def __init__(       self     :       int				,				A_     :       List[str]=2_5_0_8_8_0				,				A_     :       List[str]=2_5_6_0				,				A_     :       Optional[int]=3_6				,				A_     :       List[Any]=3_2				,				A_     :       Optional[int]=1_0_2_4_0				,				A_     :       Dict="gelu"				,				A_     :       int=0.1				,				A_     :       Optional[Any]=0.1				,				A_     :       int=5_1_4				,				A_     :       Any=1				,				A_     :       Optional[Any]=0.02				,				A_     :       str=1e-05				,				A_     :       Dict=1				,				A_     :       Any=0				,				A_     :       Tuple=2				,				A_     :       str="absolute"				,				A_     :       str=True				,				A_     :       List[str]=None				,				**A_     :       Dict				,				):
									super().__init__(pad_token_id=A_				,				bos_token_id=A_				,				eos_token_id=A_				,				**A_)
									lowerCAmelCase_			:     Tuple									= vocab_size
									lowerCAmelCase_			:     List[str]									= hidden_size
									lowerCAmelCase_			:     int									= num_hidden_layers
									lowerCAmelCase_			:     int									= num_attention_heads
									lowerCAmelCase_			:     Dict									= hidden_act
									lowerCAmelCase_			:     int									= intermediate_size
									lowerCAmelCase_			:     Tuple									= hidden_dropout_prob
									lowerCAmelCase_			:     Optional[Any]									= attention_probs_dropout_prob
									lowerCAmelCase_			:     Union[str, Any]									= max_position_embeddings
									lowerCAmelCase_			:     Dict									= type_vocab_size
									lowerCAmelCase_			:     str									= initializer_range
									lowerCAmelCase_			:     str									= layer_norm_eps
									lowerCAmelCase_			:     Optional[Any]									= position_embedding_type
									lowerCAmelCase_			:     Optional[Any]									= use_cache
									lowerCAmelCase_			:     List[str]									= classifier_dropout





class 				__snake_case						(     UpperCamelCase_						):




							@property
							def    UpperCAmelCase__			(       self     :       List[str]):
									if self.task == "multiple-choice":
											lowerCAmelCase_			:     Union[str, Any]									= {0: '''batch''', 1: '''choice''', 2: '''sequence'''}
									else:
											lowerCAmelCase_			:     List[Any]									= {0: '''batch''', 1: '''sequence'''}
									return OrderedDict(
									    [
									        ('''input_ids''', dynamic_axis),
									        ('''attention_mask''', dynamic_axis),
									    ])





