



'''simple docstring'''
# Lint as: python3

import hashlib
from typing import Union






def A__					(  UpperCAmelCase_							):
						if isinstance(UpperCAmelCase_						,						UpperCAmelCase_							):
												# Data already in bytes, returns as it as
												return hash_data
						elif isinstance(UpperCAmelCase_						,						UpperCAmelCase_							):
												# We keep the data as it as for it ot be later encoded to UTF-8
												# However replace `\\` with `/` for Windows compatibility
												_UpperCamelCase      :	Tuple				       =     hash_data.replace('\\'						,						'/'							)
						elif isinstance(UpperCAmelCase_						,						UpperCAmelCase_							):
												_UpperCamelCase      :	Any				       =     str(UpperCAmelCase_							)
						else:
												# If data is not of the required type, raise error
												raise InvalidKeyError(UpperCAmelCase_							)

						return hash_data.encode('utf-8'							)






class 							lowercase__			(							lowercase     ):





	def __init__(				self      :       int				,lowerCamelCase__      :       str				):







							'''simple docstring'''
							_UpperCamelCase      :	List[Any]				       =     '\nFAILURE TO GENERATE DATASET: Invalid key type detected'
							_UpperCamelCase      :	Union[str, Any]				       =     F'\nFound Key {hash_data} of type {type(lowerCamelCase__				)}'
							_UpperCamelCase      :	List[str]				       =     '\nKeys should be either str, int or bytes type'
							super().__init__(F'{self.prefix}{self.err_msg}{self.suffix}'				)






class 							lowercase__			(							lowercase     ):





	def __init__(				self      :       Tuple				,lowerCamelCase__      :       Dict				,lowerCamelCase__      :       List[str]				,lowerCamelCase__      :       Optional[Any]=""				):







							'''simple docstring'''
							_UpperCamelCase      :	Tuple				       =     key
							_UpperCamelCase      :	Any				       =     duplicate_key_indices
							_UpperCamelCase      :	List[str]				       =     fix_msg
							_UpperCamelCase      :	List[Any]				       =     'Found multiple examples generated with the same key'
							if len(lowerCamelCase__				) <= 20:
													_UpperCamelCase      :	Union[str, Any]				       =     F'\nThe examples at index {", ".join(lowerCamelCase__				)} have the key {key}'
							else:
													_UpperCamelCase      :	Dict				       =     F'\nThe examples at index {", ".join(duplicate_key_indices[:20]				)}... ({len(lowerCamelCase__				) - 20} more) have the key {key}'
							_UpperCamelCase      :	Union[str, Any]				       =     '\n' + fix_msg if fix_msg else ''
							super().__init__(F'{self.prefix}{self.err_msg}{self.suffix}'				)






class 							lowercase__			:





	def __init__(				self      :       Union[str, Any]				,lowerCamelCase__      :       str				):







							'''simple docstring'''
							_UpperCamelCase      :	Any				       =     hashlib.mda(_as_bytes(lowerCamelCase__				)				)





	def 			UpperCamelCase_						(				self      :       str				,lowerCamelCase__      :       Union[str, int, bytes]				):







							'''simple docstring'''
							_UpperCamelCase      :	List[Any]				       =     self._split_mda.copy()
							_UpperCamelCase      :	Tuple				       =     _as_bytes(lowerCamelCase__				)
							mda.update(lowerCamelCase__				)
							# Convert to integer with hexadecimal conversion
							return int(mda.hexdigest()				,16				)







'''simple docstring'''
import os

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


snake_case_				:			Any						 =						logging.get_logger(__name__)






class 							lowercase__			(							lowercase     ):





	def __init__(				self      :       Union[str, Any]				,lowerCamelCase__      :       Tuple				,lowerCamelCase__      :       Optional[int]=None				):







							'''simple docstring'''
							_UpperCamelCase      :	Any				       =     language
							_UpperCamelCase      :	int				       =     train_language





	def 			UpperCamelCase_						(				self      :       Optional[int]				,lowerCamelCase__      :       Dict				):







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





	def 			UpperCamelCase_						(				self      :       Optional[Any]				,lowerCamelCase__      :       List[str]				):







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





	def 			UpperCamelCase_						(				self      :       str				):







							'''simple docstring'''
							return ["contradiction", "entailment", "neutral"]
snake_case_				:			int						 =						{
    'xnli': XnliProcessor,
}

snake_case_				:			Tuple						 =						{
    'xnli': 'classification',
}

snake_case_				:			Any						 =						{
    'xnli': 3,
}


