


'''simple docstring'''






from collections import Counter
import datasets
import transformers
from transformers.convert_slow_tokenizer import SLOW_TO_FAST_CONVERTERS

from transformers.utils import logging

logging.set_verbosity_info()

a_       :     int 							=     {
    name: (getattr(transformers, name), getattr(transformers, name + "Fast")) for name in SLOW_TO_FAST_CONVERTERS
}

a_       :     Dict 							=     datasets.load_dataset("xnli", split="test+validation")

a_       :     Optional[int] 							=     0
a_       :     Any 							=     0
a_       :     str 							=     0
a_       :     Optional[Any] 							=     0






def 						_A					(lowerCAmelCase__	:Dict					,    lowerCAmelCase__	:Tuple					,    lowerCAmelCase__	:List[str]					,    lowerCAmelCase__	:Any		) ->	Optional[int]:




     '''simple docstring'''



     if spm_diff == list(reversed(lowerCAmelCase__		)		):
          # AAA -> AA+A vs A+AA case.
          return True
     elif len(lowerCAmelCase__		) == len(lowerCAmelCase__		) and fast.decode(lowerCAmelCase__		) == fast.decode(lowerCAmelCase__		):
          # Second order OK
          # Barrich -> Barr + ich vs Bar + rich
          return True
     _a         =				slow.encode(slow.decode(lowerCAmelCase__		)		)
     _a         =				fast.encode(fast.decode(lowerCAmelCase__		)		)
     if spm_reencoded != spm_diff and spm_reencoded == tok_reencoded:
          # Type 3 error.
          # Snehagatha ->
          #       Sne, h, aga, th, a
          #       Sne, ha, gat, ha
          # Encoding the wrong with sp does not even recover what spm gave us
          # It fits tokenizer however...
          return True
     return False






def 						_A					(lowerCAmelCase__	:Dict					,    lowerCAmelCase__	:Union[str, Any]					,    lowerCAmelCase__	:Any		) ->	Union[str, Any]:




     '''simple docstring'''



     _a         =				fast.encode_plus(lowerCAmelCase__		)[0]
     _a         =				enc.offsets
     _a   , _a         =				offsets[idx], offsets[idx - 1]
     if curr is not None and line[curr[0] : curr[1]] == "\u200f":
          return True
     if prev is not None and line[prev[0] : prev[1]] == "\u200f":
          return True






def 						_A					(lowerCAmelCase__	:int					,    lowerCAmelCase__	:str					,    lowerCAmelCase__	:Optional[Any]					,    lowerCAmelCase__	:Any					,    lowerCAmelCase__	:List[str]		) ->	Any:




     '''simple docstring'''



     for i, (spm_id, tok_id) in enumerate(zip(lowerCAmelCase__					,    lowerCAmelCase__		)		):
          if spm_id != tok_id:
               break
     _a         =				i
     for i, (spm_id, tok_id) in enumerate(zip(reversed(lowerCAmelCase__		)					,    reversed(lowerCAmelCase__		)		)		):
          if spm_id != tok_id:
               break
     _a         =				len(lowerCAmelCase__		) - i

     _a         =				spm_ids[first:last]
     _a         =				tok_ids[first:last]

     if check_diff(lowerCAmelCase__					,    lowerCAmelCase__					,    lowerCAmelCase__					,    lowerCAmelCase__		):
          return True

     if check_LTR_mark(lowerCAmelCase__					,    lowerCAmelCase__					,    lowerCAmelCase__		):
          return True

     if last - first > 5:
          # We might have twice a single problem, attempt to subdivide the disjointed tokens into smaller problems
          _a         =				Counter(spm_ids[first:last]		)
          _a         =				Counter(tok_ids[first:last]		)

          _a         =				{spm_ for (spm_, si) in spms.items() if toks.get(spm_					,    0		) == si}
          _a         =				3
          for i in range(last - first - min_width		):
               if all(spm_ids[first + i + j] in removable_tokens for j in range(lowerCAmelCase__		)		):
                    _a         =				[
                        k
                        for k in range(last - first - min_width		)
                        if tok_ids[first + k : first + k + min_width] == spm_ids[first + i : first + i + min_width]
                    ]
                    for j in possible_matches:
                         if check_diff(spm_ids[first : first + i]					,    tok_ids[first : first + j]					,    lowerCAmelCase__					,    lowerCAmelCase__		) and check_details(
                             lowerCAmelCase__					,    spm_ids[first + i : last]					,    tok_ids[first + j : last]					,    lowerCAmelCase__					,    lowerCAmelCase__					,    ):
                              return True

     print(f'Spm: {[fast.decode([spm_ids[i]]		) for i in range(lowerCAmelCase__					,    lowerCAmelCase__		)]}'		)
     try:
          print(f'Tok: {[fast.decode([tok_ids[i]]		) for i in range(lowerCAmelCase__					,    lowerCAmelCase__		)]}'		)
     except Exception:
          pass

     _a         =				fast.decode(spm_ids[:first]		)
     _a         =				fast.decode(spm_ids[last:]		)
     _a         =				fast.decode(spm_ids[first:last]		)
     print()
     print(lowerCAmelCase__		)
     return False






def 						_A					(lowerCAmelCase__	:Optional[Any]					,    lowerCAmelCase__	:List[Any]					,    lowerCAmelCase__	:Tuple		) ->	Dict:




     '''simple docstring'''



     global perfect
     global imperfect
     global wrong
     global total

     _a         =				slow.encode(lowerCAmelCase__		)
     _a         =				fast.encode(lowerCAmelCase__		)

     _a         =				False
     total += 1

     if slow_ids != fast_ids:
          if check_details(lowerCAmelCase__					,    lowerCAmelCase__					,    lowerCAmelCase__					,    lowerCAmelCase__					,    lowerCAmelCase__		):
               _a         =				True
               imperfect += 1
          else:
               wrong += 1
     else:
          perfect += 1

     if total % 1_00_00 == 0:
          print(f'({perfect} / {imperfect} / {wrong} ----- {perfect + imperfect + wrong})'		)

     if skip_assert:
          return

     assert (
         slow_ids == fast_ids
     ), f'line {text} : \n\n{slow_ids}\n{fast_ids}\n\n{slow.tokenize(lowerCAmelCase__		)}\n{fast.tokenize(lowerCAmelCase__		)}'






def 						_A					(lowerCAmelCase__	:List[Any]					,    lowerCAmelCase__	:Optional[Any]		) ->	str:




     '''simple docstring'''



     global batch_total
     for i in range(len(lowerCAmelCase__		)		):
          # premise, all languages
          for text in dataset[i]["premise"].values():
               test_string(lowerCAmelCase__					,    lowerCAmelCase__					,    lowerCAmelCase__		)

          # hypothesis, all languages
          for text in dataset[i]["hypothesis"]["translation"]:
               test_string(lowerCAmelCase__					,    lowerCAmelCase__					,    lowerCAmelCase__		)


if __name__ == "__main__":
 for name, (slow_class, fast_class) in TOKENIZER_CLASSES.items():
  a_       :     str 							=     list(slow_class.max_model_input_sizes.keys())
  for checkpoint in checkpoint_names:
   a_       :     Dict 							=     0
   a_       :     Any 							=     0
   a_       :     int 							=     0
   a_       :     int 							=     0

   print(f'''========================== Checking {name}: {checkpoint} ==========================''')
   a_       :     List[Any] 							=     slow_class.from_pretrained(checkpoint, force_download=True)
   a_       :     List[Any] 							=     fast_class.from_pretrained(checkpoint, force_download=True)
   test_tokenizer(slow, fast)
   print(f'''Accuracy {perfect * 1_0_0 / total:.2f}''')





'''simple docstring'''






def 						_A					(lowerCAmelCase__	:int					,    lowerCAmelCase__	:int		) ->	int:




     '''simple docstring'''



     if a < b:
          return gcd(lowerCAmelCase__					,    lowerCAmelCase__		)
     if a % b == 0:
          return b
     return gcd(lowerCAmelCase__					,    a % b		)






def 						_A					(lowerCAmelCase__	:int					,    lowerCAmelCase__	:int					,    lowerCAmelCase__	:int		) ->	int:




     '''simple docstring'''



     if y == 0:
          return 1
     _a         =				power(lowerCAmelCase__					,    y // 2					,    lowerCAmelCase__		) % mod
     _a         =				(temp * temp) % mod
     if y % 2 == 1:
          _a         =				(temp * x) % mod
     return temp






def 						_A					(lowerCAmelCase__	:int		) ->	bool:




     '''simple docstring'''



     _a         =				2
     while b < n:
          if gcd(lowerCAmelCase__					,    lowerCAmelCase__		) == 1 and power(lowerCAmelCase__					,    n - 1					,    lowerCAmelCase__		) != 1:
               return False
          b += 1
     return True


if __name__ == "__main__":
 a_       :     Any 							=     int(input("Enter number: ").strip())
 if is_carmichael_number(number):
  print(f'''{number} is a Carmichael Number.''')
 else:
  print(f'''{number} is not a Carmichael Number.''')

