



'''simple docstring'''



import unittest

from transformers.image_processing_utils import get_size_dict






class        UpperCAmelCase__						(		unittest.TestCase			):



					def 							UpperCAmelCase_			(     self  )  ->      List[Any]:
						__lowerCAmelCase       				=	{"wrong_key": 224}
						with self.assertRaises(UpperCamelCase  ):
							get_size_dict(UpperCamelCase  )

						__lowerCAmelCase       				=	{"height": 224}
						with self.assertRaises(UpperCamelCase  ):
							get_size_dict(UpperCamelCase  )

						__lowerCAmelCase       				=	{"width": 224, "shortest_edge": 224}
						with self.assertRaises(UpperCamelCase  ):
							get_size_dict(UpperCamelCase  )

						# Test a dict with the correct keys is returned as is
						__lowerCAmelCase       				=	{"height": 224, "width": 224}
						__lowerCAmelCase       				=	get_size_dict(UpperCamelCase  )
						self.assertEqual(UpperCamelCase      ,					UpperCamelCase  )

						__lowerCAmelCase       				=	{"shortest_edge": 224}
						__lowerCAmelCase       				=	get_size_dict(UpperCamelCase  )
						self.assertEqual(UpperCamelCase      ,					{"shortest_edge": 224}  )

						__lowerCAmelCase       				=	{"longest_edge": 224, "shortest_edge": 224}
						__lowerCAmelCase       				=	get_size_dict(UpperCamelCase  )
						self.assertEqual(UpperCamelCase      ,					{"longest_edge": 224, "shortest_edge": 224}  )

						# Test a single int value which  represents (size, size)
						__lowerCAmelCase       				=	get_size_dict(224  )
						self.assertEqual(UpperCamelCase      ,					{"height": 224, "width": 224}  )

						# Test a single int value which represents the shortest edge
						__lowerCAmelCase       				=	get_size_dict(224      ,					default_to_square=UpperCamelCase  )
						self.assertEqual(UpperCamelCase      ,					{"shortest_edge": 224}  )

						# Test a tuple of ints which represents (height, width)
						__lowerCAmelCase       				=	get_size_dict((150, 200)  )
						self.assertEqual(UpperCamelCase      ,					{"height": 150, "width": 200}  )

						# Test a tuple of ints which represents (width, height)
						__lowerCAmelCase       				=	get_size_dict((150, 200)      ,					height_width_order=UpperCamelCase  )
						self.assertEqual(UpperCamelCase      ,					{"height": 200, "width": 150}  )

						# Test an int representing the shortest edge and max_size which represents the longest edge
						__lowerCAmelCase       				=	get_size_dict(224      ,					max_size=256      ,					default_to_square=UpperCamelCase  )
						self.assertEqual(UpperCamelCase      ,					{"shortest_edge": 224, "longest_edge": 256}  )

						# Test int with default_to_square=True and max_size fails
						with self.assertRaises(UpperCamelCase  ):
							get_size_dict(224      ,					max_size=256      ,					default_to_square=UpperCamelCase  )


"""simple docstring"""



import os

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


SCREAMING_SNAKE_CASE_       :						Dict					=    logging.get_logger(__name__)



class        a    (							_lowerCamelCase					):



    """simple docstring"""



    def __init__(  self:			Tuple     ,    UpperCamelCase:			Optional[Any]     ,    UpperCamelCase:			Optional[int]=None							):






         """simple docstring"""


         A__				      =	language
         A__				      =	train_language

    def 					UpperCamelCase						(  self:			Union[str, Any]     ,    UpperCamelCase:			str							):






         """simple docstring"""


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

    def 					UpperCamelCase						(  self:			Dict     ,    UpperCamelCase:			Union[str, Any]							):






         """simple docstring"""


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





    def 					UpperCamelCase						(  self:			Tuple							):






         """simple docstring"""


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

SCREAMING_SNAKE_CASE_       :						int					=    {
    'xnli': XnliProcessor,
}

SCREAMING_SNAKE_CASE_       :						List[Any]					=    {
    'xnli': 'classification',
}

SCREAMING_SNAKE_CASE_       :						str					=    {
    'xnli': 3,
}






