
"""simple docstring"""
import os

from ...utils import logging
from .utils import DataProcessor, InputExample


lowercase		:						Tuple =					logging.get_logger(__name__)




class    _snake_case  (						_lowercase       ):






							def __init__(					self						:			Optional[int]						, snake_case__						:			int						, snake_case__						:			int=None    ):






												"""simple docstring"""



												__a:						Union[str, Any]		    =					language
												__a:						int		    =					train_language






							def 							__lowercase  (					self						:			Optional[Any]						, snake_case__						:			Tuple    ):






												"""simple docstring"""



												__a:						Optional[int]		    =					self.language if self.train_language is None else self.train_language
												__a:						Union[str, Any]		    =					self._read_tsv(os.path.join(snake_case__						, f"""XNLI-MT-1.0/multinli/multinli.train.{lg}.tsv"""    )    )
												__a:						Union[str, Any]		    =					[]
												for i, line in enumerate(snake_case__    ):
																	if i == 0:
																						continue
																	__a:						Dict		    =					f"""train-{i}"""
																	__a:						Optional[int]		    =					line[0]
																	__a:						int		    =					line[1]
																	__a:						List[str]		    =					"""contradiction""" if line[2] == """contradictory""" else line[2]
																	if not isinstance(snake_case__						, snake_case__    ):
																						raise ValueError(f"""Training input {text_a} is not a string"""    )
																	if not isinstance(snake_case__						, snake_case__    ):
																						raise ValueError(f"""Training input {text_b} is not a string"""    )
																	if not isinstance(snake_case__						, snake_case__    ):
																						raise ValueError(f"""Training label {label} is not a string"""    )
																	examples.append(InputExample(guid=snake_case__						, text_a=snake_case__						, text_b=snake_case__						, label=snake_case__    )    )
												return examples






							def 							__lowercase  (					self						:			Dict						, snake_case__						:			Optional[int]    ):






												"""simple docstring"""



												__a:						Any		    =					self._read_tsv(os.path.join(snake_case__						, """XNLI-1.0/xnli.test.tsv"""    )    )
												__a:						Optional[int]		    =					[]
												for i, line in enumerate(snake_case__    ):
																	if i == 0:
																						continue
																	__a:						List[str]		    =					line[0]
																	if language != self.language:
																						continue
																	__a:						int		    =					f"""test-{i}"""
																	__a:						Optional[Any]		    =					line[6]
																	__a:						Dict		    =					line[7]
																	__a:						Optional[Any]		    =					line[1]
																	if not isinstance(snake_case__						, snake_case__    ):
																						raise ValueError(f"""Training input {text_a} is not a string"""    )
																	if not isinstance(snake_case__						, snake_case__    ):
																						raise ValueError(f"""Training input {text_b} is not a string"""    )
																	if not isinstance(snake_case__						, snake_case__    ):
																						raise ValueError(f"""Training label {label} is not a string"""    )
																	examples.append(InputExample(guid=snake_case__						, text_a=snake_case__						, text_b=snake_case__						, label=snake_case__    )    )
												return examples






							def 							__lowercase  (					self						:			Tuple    ):






												"""simple docstring"""



												return ["contradiction", "entailment", "neutral"]






lowercase		:						Optional[int] =					{
    'xnli': XnliProcessor,
}

lowercase		:						Any =					{
    'xnli': 'classification',
}

lowercase		:						Optional[Any] =					{
    'xnli': 3,
}


"""simple docstring"""
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 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


lowercase		:						Tuple =					logging.get_logger(__name__)




class    _snake_case  (						_lowercase       ):
							SCREAMING_SNAKE_CASE		     =						['''pixel_values''']






							def __init__(					self						:			Union[str, Any]						, snake_case__						:			bool = True						, snake_case__						:			Optional[Dict[str, int]] = None						, snake_case__						:			PILImageResampling = PILImageResampling.BILINEAR						, snake_case__						:			bool = True						, snake_case__						:			Union[int, float] = 1 / 2_5_5						, snake_case__						:			bool = True						, snake_case__						:			Optional[Union[float, List[float]]] = None						, snake_case__						:			Optional[Union[float, List[float]]] = None						, **snake_case__						:			Optional[int]						, ):






												"""simple docstring"""



												super().__init__(**snake_case__    )
												__a:						Dict		    =					size if size is not None else {"""height""": 2_2_4, """width""": 2_2_4}
												__a:						Optional[Any]		    =					get_size_dict(snake_case__    )
												__a:						Union[str, Any]		    =					do_resize
												__a:						str		    =					do_rescale
												__a:						Tuple		    =					do_normalize
												__a:						Dict		    =					size
												__a:						str		    =					resample
												__a:						Any		    =					rescale_factor
												__a:						Optional[int]		    =					image_mean if image_mean is not None else IMAGENET_STANDARD_MEAN
												__a:						int		    =					image_std if image_std is not None else IMAGENET_STANDARD_STD






							def 							__lowercase  (					self						:			Optional[Any]						, snake_case__						:			np.ndarray						, snake_case__						:			Dict[str, int]						, snake_case__						:			PILImageResampling = PILImageResampling.BILINEAR						, snake_case__						:			Optional[Union[str, ChannelDimension]] = None						, **snake_case__						:			List[str]						, ):






												"""simple docstring"""



												__a:						int		    =					get_size_dict(snake_case__    )
												if "height" not in size or "width" not in size:
																	raise ValueError(f"""The `size` dictionary must contain the keys `height` and `width`. Got {size.keys()}"""    )
												return resize(
												    snake_case__						, size=(size["""height"""], size["""width"""])						, resample=snake_case__						, data_format=snake_case__						, **snake_case__    )






							def 							__lowercase  (					self						:			List[str]						, snake_case__						:			np.ndarray						, snake_case__						:			float						, snake_case__						:			Optional[Union[str, ChannelDimension]] = None						, **snake_case__						:			Union[str, Any]    ):






												"""simple docstring"""



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






							def 							__lowercase  (					self						:			Dict						, snake_case__						:			np.ndarray						, snake_case__						:			Union[float, List[float]]						, snake_case__						:			Union[float, List[float]]						, snake_case__						:			Optional[Union[str, ChannelDimension]] = None						, **snake_case__						:			Union[str, Any]						, ):






												"""simple docstring"""



												return normalize(snake_case__						, mean=snake_case__						, std=snake_case__						, data_format=snake_case__						, **snake_case__    )






							def 							__lowercase  (					self						:			Optional[int]						, snake_case__						:			ImageInput						, snake_case__						:			Optional[bool] = None						, snake_case__						:			Dict[str, int] = None						, snake_case__						:			PILImageResampling = None						, snake_case__						:			Optional[bool] = None						, snake_case__						:			Optional[float] = None						, snake_case__						:			Optional[bool] = None						, snake_case__						:			Optional[Union[float, List[float]]] = None						, snake_case__						:			Optional[Union[float, List[float]]] = None						, snake_case__						:			Optional[Union[str, TensorType]] = None						, snake_case__						:			Union[str, ChannelDimension] = ChannelDimension.FIRST						, **snake_case__						:			List[str]						, ):






												"""simple docstring"""



												__a:						Any		    =					do_resize if do_resize is not None else self.do_resize
												__a:						Any		    =					do_rescale if do_rescale is not None else self.do_rescale
												__a:						int		    =					do_normalize if do_normalize is not None else self.do_normalize
												__a:						Any		    =					resample if resample is not None else self.resample
												__a:						Any		    =					rescale_factor if rescale_factor is not None else self.rescale_factor
												__a:						Dict		    =					image_mean if image_mean is not None else self.image_mean
												__a:						List[str]		    =					image_std if image_std is not None else self.image_std

												__a:						int		    =					size if size is not None else self.size
												__a:						Any		    =					get_size_dict(snake_case__    )

												__a:						List[str]		    =					make_list_of_images(snake_case__    )

												if not valid_images(snake_case__    ):
																	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_rescale and rescale_factor is None:
																	raise ValueError("""Rescale factor must be specified if do_rescale is True."""    )

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

												if do_resize:
																	__a:						Dict		    =					[self.resize(image=snake_case__						, size=snake_case__						, resample=snake_case__    ) for image in images]

												if do_rescale:
																	__a:						str		    =					[self.rescale(image=snake_case__						, scale=snake_case__    ) for image in images]

												if do_normalize:
																	__a:						Dict		    =					[self.normalize(image=snake_case__						, mean=snake_case__						, std=snake_case__    ) for image in images]

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

												__a:						str		    =					{"""pixel_values""": images}
												return BatchFeature(data=snake_case__						, tensor_type=snake_case__    )
