



import gc
import unittest

from transformers import CTRLConfig, is_torch_available
from transformers.testing_utils import require_torch, slow, torch_device

from ...generation.test_utils import GenerationTesterMixin
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
      import torch

      from transformers import (
          CTRL_PRETRAINED_MODEL_ARCHIVE_LIST,
          CTRLForSequenceClassification,
          CTRLLMHeadModel,
          CTRLModel,
      )

class       _SCREAMING_SNAKE_CASE	:





     def __init__(       self :							int     ,  UpperCamelCase :							Union[str, Any]     ,  UpperCamelCase :							Optional[int]=1_4     ,  UpperCamelCase :							int=7     ,  UpperCamelCase :							Optional[Any]=True     ,  UpperCamelCase :							Dict=True     ,  UpperCamelCase :							Dict=True     ,  UpperCamelCase :							str=True     ,  UpperCamelCase :							List[Any]=True     ,  UpperCamelCase :							str=9_9     ,  UpperCamelCase :							List[str]=3_2     ,  UpperCamelCase :							Any=5     ,  UpperCamelCase :							Union[str, Any]=4     ,  UpperCamelCase :							Any=3_7     ,  UpperCamelCase :							List[Any]="gelu"     ,  UpperCamelCase :							Tuple=0.1     ,  UpperCamelCase :							Tuple=0.1     ,  UpperCamelCase :							Optional[int]=5_1_2     ,  UpperCamelCase :							List[Any]=1_6     ,  UpperCamelCase :							Optional[int]=2     ,  UpperCamelCase :							Union[str, Any]=0.0_2     ,  UpperCamelCase :							Tuple=3     ,  UpperCamelCase :							Union[str, Any]=4     ,  UpperCamelCase :							str=None     ,  )->Dict:
      __SCREAMING_SNAKE_CASE       :    List[str]       =	parent
      __SCREAMING_SNAKE_CASE       :    Dict       =	batch_size
      __SCREAMING_SNAKE_CASE       :    Tuple       =	seq_length
      __SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	is_training
      __SCREAMING_SNAKE_CASE       :    int       =	use_token_type_ids
      __SCREAMING_SNAKE_CASE       :    Any       =	use_input_mask
      __SCREAMING_SNAKE_CASE       :    List[str]       =	use_labels
      __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	use_mc_token_ids
      __SCREAMING_SNAKE_CASE       :    Tuple       =	vocab_size
      __SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	hidden_size
      __SCREAMING_SNAKE_CASE       :    Optional[int]       =	num_hidden_layers
      __SCREAMING_SNAKE_CASE       :    Any       =	num_attention_heads
      __SCREAMING_SNAKE_CASE       :    Optional[int]       =	intermediate_size
      __SCREAMING_SNAKE_CASE       :    Any       =	hidden_act
      __SCREAMING_SNAKE_CASE       :    int       =	hidden_dropout_prob
      __SCREAMING_SNAKE_CASE       :    List[Any]       =	attention_probs_dropout_prob
      __SCREAMING_SNAKE_CASE       :    Any       =	max_position_embeddings
      __SCREAMING_SNAKE_CASE       :    str       =	type_vocab_size
      __SCREAMING_SNAKE_CASE       :    List[Any]       =	type_sequence_label_size
      __SCREAMING_SNAKE_CASE       :    List[Any]       =	initializer_range
      __SCREAMING_SNAKE_CASE       :    Optional[int]       =	num_labels
      __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	num_choices
      __SCREAMING_SNAKE_CASE       :    str       =	scope
      __SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	self.vocab_size - 1





     def 	__snake_case    (       self :							str				)->Optional[int]:
      __SCREAMING_SNAKE_CASE       :    Tuple       =	ids_tensor([self.batch_size, self.seq_length]     ,  self.vocab_size				)

      __SCREAMING_SNAKE_CASE       :    List[Any]       =	None
      if self.use_input_mask:
       __SCREAMING_SNAKE_CASE       :    Tuple       =	random_attention_mask([self.batch_size, self.seq_length]				)

      __SCREAMING_SNAKE_CASE       :    List[Any]       =	None
      if self.use_token_type_ids:
       __SCREAMING_SNAKE_CASE       :    Any       =	ids_tensor([self.batch_size, self.seq_length]     ,  self.type_vocab_size				)

      __SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	None
      if self.use_mc_token_ids:
       __SCREAMING_SNAKE_CASE       :    str       =	ids_tensor([self.batch_size, self.num_choices]     ,  self.seq_length				)

      __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	None
      __SCREAMING_SNAKE_CASE       :    Dict       =	None
      __SCREAMING_SNAKE_CASE       :    int       =	None
      if self.use_labels:
       __SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	ids_tensor([self.batch_size]     ,  self.type_sequence_label_size				)
       __SCREAMING_SNAKE_CASE       :    List[str]       =	ids_tensor([self.batch_size, self.seq_length]     ,  self.num_labels				)
       __SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	ids_tensor([self.batch_size]     ,  self.num_choices				)

      __SCREAMING_SNAKE_CASE       :    List[str]       =	self.get_config()

      __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	ids_tensor([self.num_hidden_layers, self.num_attention_heads]     ,  2				)

      return (
          config,
          input_ids,
          input_mask,
          head_mask,
          token_type_ids,
          mc_token_ids,
          sequence_labels,
          token_labels,
          choice_labels,
      )





     def 	__snake_case    (       self :							List[str]				)->List[Any]:
      return CTRLConfig(
          vocab_size=self.vocab_size     ,  n_embd=self.hidden_size     ,  n_layer=self.num_hidden_layers     ,  n_head=self.num_attention_heads     ,  n_positions=self.max_position_embeddings     ,  pad_token_id=self.pad_token_id     ,  )





     def 	__snake_case    (       self :							str     ,  UpperCamelCase :							Optional[Any]     ,  UpperCamelCase :							Tuple     ,  UpperCamelCase :							Tuple     ,  UpperCamelCase :							Tuple     ,  UpperCamelCase :							Optional[int]     ,  *UpperCamelCase :							int				)->Optional[int]:
      __SCREAMING_SNAKE_CASE       :    List[Any]       =	CTRLModel(config=UpperCamelCase				)
      model.to(UpperCamelCase				)
      model.eval()

      model(UpperCamelCase     ,  token_type_ids=UpperCamelCase     ,  head_mask=UpperCamelCase				)
      model(UpperCamelCase     ,  token_type_ids=UpperCamelCase				)
      __SCREAMING_SNAKE_CASE       :    Any       =	model(UpperCamelCase				)
      self.parent.assertEqual(result.last_hidden_state.shape     ,  (self.batch_size, self.seq_length, self.hidden_size)				)
      self.parent.assertEqual(len(result.past_key_values				)     ,  config.n_layer				)





     def 	__snake_case    (       self :							Union[str, Any]     ,  UpperCamelCase :							List[str]     ,  UpperCamelCase :							List[str]     ,  UpperCamelCase :							Any     ,  UpperCamelCase :							Optional[int]     ,  UpperCamelCase :							Optional[Any]     ,  *UpperCamelCase :							Optional[Any]				)->List[Any]:
      __SCREAMING_SNAKE_CASE       :    List[str]       =	CTRLLMHeadModel(UpperCamelCase				)
      model.to(UpperCamelCase				)
      model.eval()

      __SCREAMING_SNAKE_CASE       :    Optional[int]       =	model(UpperCamelCase     ,  token_type_ids=UpperCamelCase     ,  labels=UpperCamelCase				)
      self.parent.assertEqual(result.loss.shape     ,  ()				)
      self.parent.assertEqual(result.logits.shape     ,  (self.batch_size, self.seq_length, self.vocab_size)				)





     def 	__snake_case    (       self :							Optional[int]				)->str:
      __SCREAMING_SNAKE_CASE       :    int       =	self.prepare_config_and_inputs()

      (
          (
          __SCREAMING_SNAKE_CASE
      ),		(
          __SCREAMING_SNAKE_CASE
      ),		(
          __SCREAMING_SNAKE_CASE
      ),		(
          __SCREAMING_SNAKE_CASE
      ),		(
          __SCREAMING_SNAKE_CASE
      ),		(
          __SCREAMING_SNAKE_CASE
      ),		(
          __SCREAMING_SNAKE_CASE
      ),		(
          __SCREAMING_SNAKE_CASE
      ),		(
          __SCREAMING_SNAKE_CASE
      ),		
      )       :    Tuple       =	config_and_inputs

      __SCREAMING_SNAKE_CASE       :    List[str]       =	{"input_ids": input_ids, "token_type_ids": token_type_ids, "head_mask": head_mask}

      return config, inputs_dict






     def 	__snake_case    (       self :							Optional[Any]     ,  UpperCamelCase :							Optional[Any]     ,  UpperCamelCase :							Union[str, Any]     ,  UpperCamelCase :							Union[str, Any]     ,  UpperCamelCase :							Optional[Any]     ,  *UpperCamelCase :							List[Any]				)->List[Any]:
      __SCREAMING_SNAKE_CASE       :    int       =	self.num_labels
      __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	CTRLForSequenceClassification(UpperCamelCase				)
      model.to(UpperCamelCase				)
      model.eval()
      __SCREAMING_SNAKE_CASE       :    List[Any]       =	ids_tensor([self.batch_size]     ,  self.type_sequence_label_size				)
      __SCREAMING_SNAKE_CASE       :    str       =	model(UpperCamelCase     ,  token_type_ids=UpperCamelCase     ,  labels=UpperCamelCase				)
      self.parent.assertEqual(result.logits.shape     ,  (self.batch_size, self.num_labels)				)






@require_torch
class       _SCREAMING_SNAKE_CASE	(UpperCamelCase			,    UpperCamelCase			,    UpperCamelCase			,    unittest.TestCase ):
     lowerCAmelCase					=			(CTRLModel, CTRLLMHeadModel, CTRLForSequenceClassification) if is_torch_available() else ()
     lowerCAmelCase					=			(CTRLLMHeadModel,) if is_torch_available() else ()
     lowerCAmelCase					=			(
         {
             """feature-extraction""": CTRLModel,
             """text-classification""": CTRLForSequenceClassification,
             """text-generation""": CTRLLMHeadModel,
             """zero-shot""": CTRLForSequenceClassification,
         }
         if is_torch_available()
         else {}
     )
     lowerCAmelCase					=			True
     lowerCAmelCase					=			False
     lowerCAmelCase					=			False





     def 	__snake_case    (       self :							List[str]     ,  UpperCamelCase :							int     ,  UpperCamelCase :							Optional[int]     ,  UpperCamelCase :							str     ,  UpperCamelCase :							Any     ,  UpperCamelCase :							Optional[Any]				)->Optional[int]:
      if pipeline_test_casse_name == "ZeroShotClassificationPipelineTests":
       # Get `tokenizer does not have a padding token` error for both fast/slow tokenizers.
       # `CTRLConfig` was never used in pipeline tests, either because of a missing checkpoint or because a tiny
       # config could not be created.
       return True

      return False





     def 	__snake_case    (       self :							List[str]				)->str:
      __SCREAMING_SNAKE_CASE       :    List[str]       =	CTRLModelTester(self				)
      __SCREAMING_SNAKE_CASE       :    Any       =	ConfigTester(self     ,  config_class=UpperCamelCase     ,  n_embd=3_7				)





     def 	__snake_case    (       self :							Union[str, Any]				)->Optional[int]:
      super().tearDown()
      # clean-up as much as possible GPU memory occupied by PyTorch
      gc.collect()
      torch.cuda.empty_cache()





     def 	__snake_case    (       self :							List[str]				)->Optional[Any]:
      self.config_tester.run_common_tests()





     def 	__snake_case    (       self :							Any				)->List[str]:
      __SCREAMING_SNAKE_CASE       :    str       =	self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_ctrl_model(*UpperCamelCase				)





     def 	__snake_case    (       self :							Optional[int]				)->Tuple:
      __SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_lm_head_model(*UpperCamelCase				)





     @unittest.skip("Will be fixed soon by reducing the size of the model used for common tests."				)
     def 	__snake_case    (       self :							Optional[int]				)->Any:
      pass





     @slow
     def 	__snake_case    (       self :							Optional[Any]				)->Optional[Any]:
      for model_name in CTRL_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
       __SCREAMING_SNAKE_CASE       :    Dict       =	CTRLModel.from_pretrained(UpperCamelCase				)
       self.assertIsNotNone(UpperCamelCase				)






     @unittest.skip("The model doesn't support left padding"				)  # and it's not used enough to be worth fixing :)
     def 	__snake_case    (       self :							List[Any]				)->List[str]:
      pass






@require_torch
class       _SCREAMING_SNAKE_CASE	(unittest.TestCase ):





     def 	__snake_case    (       self :							Optional[int]				)->Optional[Any]:
      super().tearDown()
      # clean-up as much as possible GPU memory occupied by PyTorch
      gc.collect()
      torch.cuda.empty_cache()






     @slow
     def 	__snake_case    (       self :							List[str]				)->Optional[int]:
      __SCREAMING_SNAKE_CASE       :    Tuple       =	CTRLLMHeadModel.from_pretrained("ctrl"				)
      model.to(UpperCamelCase				)
      __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	torch.tensor(
          [[1_1_8_5_9, 0, 1_6_1_1, 8]]     ,  dtype=torch.long     ,  device=UpperCamelCase				)  # Legal the president is
      __SCREAMING_SNAKE_CASE       :    List[Any]       =	[
          1_1_8_5_9,
          0,
          1_6_1_1,
          8,
          5,
          1_5_0,
          2_6_4_4_9,
          2,
          1_9,
          3_4_8,
          4_6_9,
          3,
          2_5_9_5,
          4_8,
          2_0_7_4_0,
          2_4_6_5_3_3,
          2_4_6_5_3_3,
          1_9,
          3_0,
          5,
      ]  # Legal the president is a good guy and I don't want to lose my job. \n \n I have a

      __SCREAMING_SNAKE_CASE       :    Optional[int]       =	model.generate(UpperCamelCase     ,  do_sample=UpperCamelCase				)
      self.assertListEqual(output_ids[0].tolist()     ,  UpperCamelCase				)











import logging
import os
from dataclasses import dataclass
from typing import List, Optional, Union

import tqdm
from filelock import FileLock

from transformers import (
    BartTokenizer,
    BartTokenizerFast,
    DataProcessor,
    PreTrainedTokenizer,
    RobertaTokenizer,
    RobertaTokenizerFast,
    XLMRobertaTokenizer,
    is_tf_available,
    is_torch_available,
)


_lowerCamelCase						    =  logging.getLogger(__name__)

@dataclass(frozen=UpperCamelCase )
class       _SCREAMING_SNAKE_CASE	:
     lowerCAmelCase					=			42
     lowerCAmelCase					=			42
     lowerCAmelCase					=			None
     lowerCAmelCase					=			None
     lowerCAmelCase					=			None






@dataclass(frozen=UpperCamelCase )
class       _SCREAMING_SNAKE_CASE	:
     lowerCAmelCase					=			42
     lowerCAmelCase					=			None
     lowerCAmelCase					=			None
     lowerCAmelCase					=			None
     lowerCAmelCase					=			None


if is_torch_available():
      import torch
      from torch.utils.data import Dataset

      class       _SCREAMING_SNAKE_CASE	(UpperCamelCase ):
           lowerCAmelCase					=			42





           def __init__(       self :							str     ,  UpperCamelCase :							str     ,  UpperCamelCase :							PreTrainedTokenizer     ,  UpperCamelCase :							str     ,  UpperCamelCase :							Optional[int] = None     ,  UpperCamelCase :							Union[str, Any]=False     ,  UpperCamelCase :							bool = False     ,  )->List[str]:
            __SCREAMING_SNAKE_CASE       :    int       =	hans_processors[task]()

            __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	os.path.join(
                UpperCamelCase     ,  "cached_{}_{}_{}_{}".format(
                    "dev" if evaluate else "train"     ,  tokenizer.__class__.__name__     ,  str(UpperCamelCase				)     ,  UpperCamelCase     ,  )     ,  )
            __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	processor.get_labels()
            if tokenizer.__class__ in (
                RobertaTokenizer,
                RobertaTokenizerFast,
                XLMRobertaTokenizer,
                BartTokenizer,
                BartTokenizerFast,
            ):
             # HACK(label indices are swapped in RoBERTa pretrained model)
             __SCREAMING_SNAKE_CASE,		__SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	label_list[2], label_list[1]
            __SCREAMING_SNAKE_CASE       :    Any       =	label_list

            # Make sure only the first process in distributed training processes the dataset,
            # and the others will use the cache.
            __SCREAMING_SNAKE_CASE       :    str       =	cached_features_file + ".lock"
            with FileLock(UpperCamelCase				):
             if os.path.exists(UpperCamelCase				) and not overwrite_cache:
              logger.info(F"""Loading features from cached file {cached_features_file}"""				)
              __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	torch.load(UpperCamelCase				)
             else:
              logger.info(F"""Creating features from dataset file at {data_dir}"""				)

              __SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	(
                  processor.get_dev_examples(UpperCamelCase				) if evaluate else processor.get_train_examples(UpperCamelCase				)
              )

              logger.info("Training examples: %s"     ,  len(UpperCamelCase				)				)
              __SCREAMING_SNAKE_CASE       :    Any       =	hans_convert_examples_to_features(UpperCamelCase     ,  UpperCamelCase     ,  UpperCamelCase     ,  UpperCamelCase				)
              logger.info("Saving features into cached file %s"     ,  UpperCamelCase				)
              torch.save(self.features     ,  UpperCamelCase				)





           def __len__(       self :							Tuple				)->Any:
            return len(self.features				)





           def __getitem__(       self :							Union[str, Any]     ,  UpperCamelCase :							int				)->InputFeatures:
            return self.features[i]






           def 	__snake_case    (       self :							int				)->Tuple:
            return self.label_list


if is_tf_available():
      import tensorflow as tf

      class       _SCREAMING_SNAKE_CASE	:
           lowerCAmelCase					=			42





           def __init__(       self :							Dict     ,  UpperCamelCase :							str     ,  UpperCamelCase :							PreTrainedTokenizer     ,  UpperCamelCase :							str     ,  UpperCamelCase :							Optional[int] = 1_2_8     ,  UpperCamelCase :							Union[str, Any]=False     ,  UpperCamelCase :							bool = False     ,  )->str:
            __SCREAMING_SNAKE_CASE       :    str       =	hans_processors[task]()
            __SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	processor.get_labels()
            if tokenizer.__class__ in (
                RobertaTokenizer,
                RobertaTokenizerFast,
                XLMRobertaTokenizer,
                BartTokenizer,
                BartTokenizerFast,
            ):
             # HACK(label indices are swapped in RoBERTa pretrained model)
             __SCREAMING_SNAKE_CASE,		__SCREAMING_SNAKE_CASE       :    List[str]       =	label_list[2], label_list[1]
            __SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	label_list

            __SCREAMING_SNAKE_CASE       :    str       =	processor.get_dev_examples(UpperCamelCase				) if evaluate else processor.get_train_examples(UpperCamelCase				)
            __SCREAMING_SNAKE_CASE       :    str       =	hans_convert_examples_to_features(UpperCamelCase     ,  UpperCamelCase     ,  UpperCamelCase     ,  UpperCamelCase				)

            def gen():
             for ex_index, ex in tqdm.tqdm(enumerate(self.features				)     ,  desc="convert examples to features"				):
              if ex_index % 1_0_0_0_0 == 0:
               logger.info("Writing example %d of %d" % (ex_index, len(UpperCamelCase				))				)

              yield (
                  {
                      "example_id": 0,
                      "input_ids": ex.input_ids,
                      "attention_mask": ex.attention_mask,
                      "token_type_ids": ex.token_type_ids,
                  },
                  ex.label,
              )

            __SCREAMING_SNAKE_CASE       :    List[str]       =	tf.data.Dataset.from_generator(
                UpperCamelCase     ,  (
                    {
                        "example_id": tf.intaa,
                        "input_ids": tf.intaa,
                        "attention_mask": tf.intaa,
                        "token_type_ids": tf.intaa,
                    },
                    tf.intaa,
                )     ,  (
                    {
                        "example_id": tf.TensorShape([]				),
                        "input_ids": tf.TensorShape([None, None]				),
                        "attention_mask": tf.TensorShape([None, None]				),
                        "token_type_ids": tf.TensorShape([None, None]				),
                    },
                    tf.TensorShape([]				),
                )     ,  )





           def 	__snake_case    (       self :							List[Any]				)->str:
            return self.dataset





           def __len__(       self :							Tuple				)->List[str]:
            return len(self.features				)





           def __getitem__(       self :							Optional[Any]     ,  UpperCamelCase :							Tuple				)->InputFeatures:
            return self.features[i]






           def 	__snake_case    (       self :							List[Any]				)->Optional[int]:
            return self.label_list

class       _SCREAMING_SNAKE_CASE	(UpperCamelCase ):





     def 	__snake_case    (       self :							List[Any]     ,  UpperCamelCase :							Union[str, Any]				)->Tuple:
      return self._create_examples(self._read_tsv(os.path.join(UpperCamelCase     ,  "heuristics_train_set.txt"				)				)     ,  "train"				)





     def 	__snake_case    (       self :							List[str]     ,  UpperCamelCase :							Optional[int]				)->Any:
      return self._create_examples(self._read_tsv(os.path.join(UpperCamelCase     ,  "heuristics_evaluation_set.txt"				)				)     ,  "dev"				)





     def 	__snake_case    (       self :							Optional[int]				)->Tuple:
      return ["contradiction", "entailment", "neutral"]






     def 	__snake_case    (       self :							List[str]     ,  UpperCamelCase :							str     ,  UpperCamelCase :							Any				)->Tuple:
      __SCREAMING_SNAKE_CASE       :    Optional[int]       =	[]
      for i, line in enumerate(UpperCamelCase				):
       if i == 0:
        continue
       __SCREAMING_SNAKE_CASE       :    str       =	"%s-%s" % (set_type, line[0])
       __SCREAMING_SNAKE_CASE       :    List[str]       =	line[5]
       __SCREAMING_SNAKE_CASE       :    List[str]       =	line[6]
       __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	line[7][2:] if line[7].startswith("ex"				) else line[7]
       __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	line[0]
       examples.append(InputExample(guid=UpperCamelCase     ,  text_a=UpperCamelCase     ,  text_b=UpperCamelCase     ,  label=UpperCamelCase     ,  pairID=UpperCamelCase				)				)
      return examples






def 	_lowerCAmelCase						(				__lowerCamelCase   :     List[InputExample]		,	__lowerCamelCase   :     List[str]		,	__lowerCamelCase   :     int		,	__lowerCamelCase   :     PreTrainedTokenizer		,	):



 """simple docstring"""





 __SCREAMING_SNAKE_CASE       :    str       =	{label: i for i, label in enumerate(__lowerCamelCase     )}

 __SCREAMING_SNAKE_CASE       :    Any       =	[]
 for ex_index, example in tqdm.tqdm(enumerate(__lowerCamelCase     )		,	desc="convert examples to features"     ):
  if ex_index % 10000 == 0:
   logger.info("Writing example %d" % (ex_index)     )

  __SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	tokenizer(
      example.text_a		,	example.text_b		,	add_special_tokens=__lowerCamelCase		,	max_length=__lowerCamelCase		,	padding="max_length"		,	truncation=__lowerCamelCase		,	return_overflowing_tokens=__lowerCamelCase		,	)

  __SCREAMING_SNAKE_CASE       :    List[str]       =	label_map[example.label] if example.label in label_map else 0

  __SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	int(example.pairID     )

  features.append(InputFeatures(**__lowerCamelCase		,	label=__lowerCamelCase		,	pairID=__lowerCamelCase     )     )

 for i, example in enumerate(examples[:5]     ):
  logger.info("*** Example ***"     )
  logger.info(F"""guid: {example}"""     )
  logger.info(F"""features: {features[i]}"""     )

 return features


_lowerCamelCase						    =  {
    """hans""": 3,
}






_lowerCamelCase						    =  {
    """hans""": HansProcessor,
}






