
"""simple docstring"""

import os
import time
import warnings
from dataclasses import dataclass, field
from enum import Enum
from typing import List, Optional, Union

import torch
from filelock import FileLock
from torch.utils.data import Dataset

from ...tokenization_utils_base import PreTrainedTokenizerBase
from ...utils import logging
from ..processors.glue import glue_convert_examples_to_features, glue_output_modes, glue_processors
from ..processors.utils import InputFeatures


SCREAMING_SNAKE_CASE_            =    logging.get_logger(__name__)
@dataclass
class   _UpperCAmelCase				:
      __SCREAMING_SNAKE_CASE :				str				   =						field(metadata={"help": "The name of the task to train on: " + ", ".join(glue_processors.keys()				)}				)
      __SCREAMING_SNAKE_CASE :				str				   =						field(
          metadata={"help": "The input data dir. Should contain the .tsv files (or other data files) for the task."}				)
      __SCREAMING_SNAKE_CASE :				int				   =						field(
          default=1_2_8  ,      metadata={
              "help": (
                  "The maximum total input sequence length after tokenization. Sequences longer "
                  "than this will be truncated, sequences shorter will be padded."
              )
          }  ,      )
      __SCREAMING_SNAKE_CASE :				bool				   =						field(
          default=SCREAMING_SNAKE_CASE_  ,      metadata={"help": "Overwrite the cached training and evaluation sets"}				)




      def      a_   (				self				)    ->       Tuple:
          UpperCAmelCase          =       self.task_name.lower()

class   _UpperCAmelCase				(		SCREAMING_SNAKE_CASE_				):
      __SCREAMING_SNAKE_CASE :				Dict				   =						"train"
      __SCREAMING_SNAKE_CASE :				List[str]				   =						"dev"
      __SCREAMING_SNAKE_CASE :				Dict				   =						"test"

class   _UpperCAmelCase				(		SCREAMING_SNAKE_CASE_				):
      __SCREAMING_SNAKE_CASE :				GlueDataTrainingArguments
      __SCREAMING_SNAKE_CASE :				str
      __SCREAMING_SNAKE_CASE :				List[InputFeatures]




      def __init__(				self ,							lowercase_ ,							lowercase_ ,							lowercase_ = None ,							lowercase_ = Split.train ,							lowercase_ = None ,							)    ->       str:
          warnings.warn(
              'This dataset will be removed from the library soon, preprocessing should be handled with the 🤗 Datasets '
              'library. You can have a look at this example script for pointers: '
              'https://github.com/huggingface/transformers/blob/main/examples/pytorch/text-classification/run_glue.py' ,							lowercase_ ,							)
          UpperCAmelCase          =       args
          UpperCAmelCase          =       glue_processors[args.task_name]()
          UpperCAmelCase          =       glue_output_modes[args.task_name]
          if isinstance(lowercase_ ,							lowercase_				):
              try:
                  UpperCAmelCase          =       Split[mode]
              except KeyError:
                  raise KeyError('mode is not a valid split name'				)
        # Load data features from cache or dataset file
          UpperCAmelCase          =       os.path.join(
              cache_dir if cache_dir is not None else args.data_dir ,							F"cached_{mode.value}_{tokenizer.__class__.__name__}_{args.max_seq_length}_{args.task_name}" ,							)
          UpperCAmelCase          =       self.processor.get_labels()
          if args.task_name in ["mnli", "mnli-mm"] and tokenizer.__class__.__name__ in (
              "RobertaTokenizer",
              "RobertaTokenizerFast",
              "XLMRobertaTokenizer",
              "BartTokenizer",
              "BartTokenizerFast",
          ):
              # HACK(label indices are swapped in RoBERTa pretrained model)
              UpperCAmelCase      ,				UpperCAmelCase          =       label_list[2], label_list[1]
          UpperCAmelCase          =       label_list

          # Make sure only the first process in distributed training processes the dataset,
          # and the others will use the cache.
          UpperCAmelCase          =       cached_features_file + '.lock'
          with FileLock(lowercase_				):
              if os.path.exists(lowercase_				) and not args.overwrite_cache:
                  UpperCAmelCase          =       time.time()
                  UpperCAmelCase          =       torch.load(lowercase_				)
                  logger.info(
                      F"Loading features from cached file {cached_features_file} [took %.3f s]" ,							time.time() - start				)
              else:
                  logger.info(F"Creating features from dataset file at {args.data_dir}"				)

                  if mode == Split.dev:
                      UpperCAmelCase          =       self.processor.get_dev_examples(args.data_dir				)
                  elif mode == Split.test:
                      UpperCAmelCase          =       self.processor.get_test_examples(args.data_dir				)
                  else:
                      UpperCAmelCase          =       self.processor.get_train_examples(args.data_dir				)
                  if limit_length is not None:
                      UpperCAmelCase          =       examples[:limit_length]
                  UpperCAmelCase          =       glue_convert_examples_to_features(
                      lowercase_ ,							lowercase_ ,							max_length=args.max_seq_length ,							label_list=lowercase_ ,							output_mode=self.output_mode ,							)
                  UpperCAmelCase          =       time.time()
                  torch.save(self.features ,							lowercase_				)
                  # ^ This seems to take a lot of time so I want to investigate why and how we can improve.
                  logger.info(
                      F"Saving features into cached file {cached_features_file} [took {time.time() - start:.3f} s]"				)




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




      def __getitem__(				self ,							lowercase_				)    ->       InputFeatures:
          return self.features[i]




      def      a_   (				self				)    ->       Optional[int]:
          return self.label_list





"""simple docstring"""

import math




def      lowercase__    (       lowerCAmelCase					:       str			,					lowerCAmelCase					:       Optional[Any]			)			->   List[Any]:






    """simple docstring"""




    if 0 not in (x, y):
        # We use the relation x^y = y*log10(x), where 10 is the base.
        return y * math.logaa(lowerCAmelCase			)
    else:
        if x == 0:  # 0 raised to any number is 0
            return 0
        elif y == 0:
            return 1  # any number raised to 0 is 1
    raise AssertionError('This should never happen'			)


if __name__ == "__main__":  # Main function
   # Read two numbers from input and typecast them to int using map function.
   # Here x is the base and y is the power.
   SCREAMING_SNAKE_CASE_            =    '''Enter the base and the power separated by a comma: '''
   SCREAMING_SNAKE_CASE_       ,    SCREAMING_SNAKE_CASE_            =    map(int, input(prompt).split(''','''))
   SCREAMING_SNAKE_CASE_       ,    SCREAMING_SNAKE_CASE_            =    map(int, input(prompt).split(''','''))

   # We find the log of each number, using the function res(), which takes two
   # arguments.
   SCREAMING_SNAKE_CASE_            =    res(xa, ya)
   SCREAMING_SNAKE_CASE_            =    res(xa, ya)

   # We check for the largest number
   if resa > resa:
      print('''Largest number is''', xa, '''^''', ya)
   elif resa > resa:
      print('''Largest number is''', xa, '''^''', ya)
   else:
      print('''Both are equal''')



