






from typing import Optional, Union

import numpy as np

from ...image_processing_utils import BaseImageProcessor, BatchFeature
from ...image_transforms import get_image_size, pad, rescale, to_channel_dimension_format
from ...image_utils import ChannelDimension, ImageInput, make_list_of_images, to_numpy_array, valid_images
from ...utils import TensorType, logging


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


class 							__UpperCamelCase     (  _lowerCAmelCase ):
	__snake_case						:Dict =							['pixel_values']







	def __init__(	self   :				int							,					_lowerCAmelCase   :				bool = True							,					_lowerCAmelCase   :				Union[int, float] = 1 / 255							,					_lowerCAmelCase   :				bool = True							,					_lowerCAmelCase   :				int = 8							,					**_lowerCAmelCase   :				str							,					)		->			None:
		"""simple docstring"""







		super().__init__(**_lowerCAmelCase      )

		__lowercase   							=	do_rescale
		__lowercase   							=	rescale_factor
		__lowercase   							=	do_pad
		__lowercase   							=	pad_size







	def 			_a (	self   :				Any							,					_lowerCAmelCase   :				np.ndarray							,					_lowerCAmelCase   :				float							,					_lowerCAmelCase   :				Optional[Union[str, ChannelDimension]] = None							,					**_lowerCAmelCase   :				Any      )		->			np.ndarray:
		"""simple docstring"""







		return rescale(_lowerCAmelCase							,					scale=_lowerCAmelCase							,					data_format=_lowerCAmelCase							,					**_lowerCAmelCase      )







	def 			_a (	self   :				Optional[int]							,					_lowerCAmelCase   :				np.ndarray							,					_lowerCAmelCase   :				int							,					_lowerCAmelCase   :				Optional[Union[str, ChannelDimension]] = None      )		->			str:
		"""simple docstring"""







		__lowercase							,    __lowercase   							=	get_image_size(_lowerCAmelCase      )
		__lowercase   							=	(old_height // size + 1) * size - old_height
		__lowercase   							=	(old_width // size + 1) * size - old_width

		return pad(_lowerCAmelCase							,					((0, pad_height), (0, pad_width))							,					mode="""symmetric"""							,					data_format=_lowerCAmelCase      )







	def 			_a (	self   :				List[Any]							,					_lowerCAmelCase   :				ImageInput							,					_lowerCAmelCase   :				Optional[bool] = None							,					_lowerCAmelCase   :				Optional[float] = None							,					_lowerCAmelCase   :				Optional[bool] = None							,					_lowerCAmelCase   :				Optional[int] = None							,					_lowerCAmelCase   :				Optional[Union[str, TensorType]] = None							,					_lowerCAmelCase   :				Union[str, ChannelDimension] = ChannelDimension.FIRST							,					**_lowerCAmelCase   :				Any							,					)		->			Any:
		"""simple docstring"""







		__lowercase   							=	do_rescale if do_rescale is not None else self.do_rescale
		__lowercase   							=	rescale_factor if rescale_factor is not None else self.rescale_factor
		__lowercase   							=	do_pad if do_pad is not None else self.do_pad
		__lowercase   							=	pad_size if pad_size is not None else self.pad_size

		__lowercase   							=	make_list_of_images(_lowerCAmelCase      )

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

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

		# All transformations expect numpy arrays.
		__lowercase   							=	[to_numpy_array(_lowerCAmelCase      ) for image in images]

		if do_rescale:
			__lowercase   							=	[self.rescale(image=_lowerCAmelCase							,					scale=_lowerCAmelCase      ) for image in images]

		if do_pad:
			__lowercase   							=	[self.pad(_lowerCAmelCase							,					size=_lowerCAmelCase      ) for image in images]

		__lowercase   							=	[to_channel_dimension_format(_lowerCAmelCase							,					_lowerCAmelCase      ) for image in images]

		__lowercase   							=	{"""pixel_values""": images}
		return BatchFeature(data=_lowerCAmelCase							,					tensor_type=_lowerCAmelCase      )




from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available


__snake_case				:      Optional[int]   		=			{
    """configuration_xlm""": ["""XLM_PRETRAINED_CONFIG_ARCHIVE_MAP""", """XLMConfig""", """XLMOnnxConfig"""],
    """tokenization_xlm""": ["""XLMTokenizer"""],
}

try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	__snake_case				:      Optional[Any]   		=			[
	    """XLM_PRETRAINED_MODEL_ARCHIVE_LIST""",
	    """XLMForMultipleChoice""",
	    """XLMForQuestionAnswering""",
	    """XLMForQuestionAnsweringSimple""",
	    """XLMForSequenceClassification""",
	    """XLMForTokenClassification""",
	    """XLMModel""",
	    """XLMPreTrainedModel""",
	    """XLMWithLMHeadModel""",
	]

try:
	if not is_tf_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	__snake_case				:      Optional[Any]   		=			[
	    """TF_XLM_PRETRAINED_MODEL_ARCHIVE_LIST""",
	    """TFXLMForMultipleChoice""",
	    """TFXLMForQuestionAnsweringSimple""",
	    """TFXLMForSequenceClassification""",
	    """TFXLMForTokenClassification""",
	    """TFXLMMainLayer""",
	    """TFXLMModel""",
	    """TFXLMPreTrainedModel""",
	    """TFXLMWithLMHeadModel""",
	]


if TYPE_CHECKING:
	from .configuration_xlm import XLM_PRETRAINED_CONFIG_ARCHIVE_MAP, XLMConfig, XLMOnnxConfig
	from .tokenization_xlm import XLMTokenizer

	try:
		if not is_torch_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_xlm import (
		    XLM_PRETRAINED_MODEL_ARCHIVE_LIST,
		    XLMForMultipleChoice,
		    XLMForQuestionAnswering,
		    XLMForQuestionAnsweringSimple,
		    XLMForSequenceClassification,
		    XLMForTokenClassification,
		    XLMModel,
		    XLMPreTrainedModel,
		    XLMWithLMHeadModel,
		)

	try:
		if not is_tf_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_tf_xlm import (
		    TF_XLM_PRETRAINED_MODEL_ARCHIVE_LIST,
		    TFXLMForMultipleChoice,
		    TFXLMForQuestionAnsweringSimple,
		    TFXLMForSequenceClassification,
		    TFXLMForTokenClassification,
		    TFXLMMainLayer,
		    TFXLMModel,
		    TFXLMPreTrainedModel,
		    TFXLMWithLMHeadModel,
		)

else:
	import sys

	__snake_case				:      Union[str, Any]   		=			_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)


