





"""simple docstring"""


import os
from typing import List, Union

import tensorflow as tf
from tensorflow_text import BertTokenizer as BertTokenizerLayer
from tensorflow_text import FastBertTokenizer, ShrinkLongestTrimmer, case_fold_utfa, combine_segments, pad_model_inputs

from .tokenization_bert import BertTokenizer



class      lowercase_				(     tf.keras.layers.Layer							):

       def __init__(			self   ,					__SCREAMING_SNAKE_CASE   ,					__SCREAMING_SNAKE_CASE   ,					__SCREAMING_SNAKE_CASE = None   ,					__SCREAMING_SNAKE_CASE = None   ,					__SCREAMING_SNAKE_CASE = None   ,					__SCREAMING_SNAKE_CASE = "longest"   ,					__SCREAMING_SNAKE_CASE = True   ,					__SCREAMING_SNAKE_CASE = 512   ,					__SCREAMING_SNAKE_CASE = None   ,					__SCREAMING_SNAKE_CASE = True   ,					__SCREAMING_SNAKE_CASE = True   ,					__SCREAMING_SNAKE_CASE = True   ,					**__SCREAMING_SNAKE_CASE   ,					):






        '''simple docstring'''

        super().__init__()
        if use_fast_bert_tokenizer:
         snake_case__    							=				FastBertTokenizer(
             __SCREAMING_SNAKE_CASE   ,					token_out_type=tf.intaa   ,					lower_case_nfd_strip_accents=__SCREAMING_SNAKE_CASE   ,					**__SCREAMING_SNAKE_CASE     )
        else:
         snake_case__    							=				tf.lookup.StaticVocabularyTable(
             tf.lookup.KeyValueTensorInitializer(
                 keys=__SCREAMING_SNAKE_CASE   ,					key_dtype=tf.string   ,					values=tf.range(tf.size(__SCREAMING_SNAKE_CASE   ,					out_type=tf.intaa     )   ,					dtype=tf.intaa     )   ,					value_dtype=tf.intaa   ,					)   ,					num_oov_buckets=1   ,					)
         snake_case__    							=				BertTokenizerLayer(
             __SCREAMING_SNAKE_CASE   ,					token_out_type=tf.intaa   ,					lower_case=__SCREAMING_SNAKE_CASE   ,					**__SCREAMING_SNAKE_CASE     )

        snake_case__    							=				vocab_list
        snake_case__    							=				do_lower_case
        snake_case__    							=				cls_token_id or vocab_list.index("[CLS]"     )
        snake_case__    							=				sep_token_id or vocab_list.index("[SEP]"     )
        snake_case__    							=				pad_token_id or vocab_list.index("[PAD]"     )
        snake_case__    							=				ShrinkLongestTrimmer(max_length - 3   ,					axis=1     )  # Allow room for special tokens
        snake_case__    							=				max_length
        snake_case__    							=				padding
        snake_case__    							=				truncation
        snake_case__    							=				pad_to_multiple_of
        snake_case__    							=				return_token_type_ids
        snake_case__    							=				return_attention_mask

       @classmethod
       def 		_SCREAMING_SNAKE_CASE(			cls   ,					__SCREAMING_SNAKE_CASE   ,					**__SCREAMING_SNAKE_CASE     ):  # noqa: F821






        '''simple docstring'''

        snake_case__    							=				kwargs.pop("do_lower_case"   ,					__SCREAMING_SNAKE_CASE     )
        snake_case__    							=				tokenizer.do_lower_case if do_lower_case is None else do_lower_case
        snake_case__    							=				kwargs.pop("cls_token_id"   ,					__SCREAMING_SNAKE_CASE     )
        snake_case__    							=				tokenizer.cls_token_id if cls_token_id is None else cls_token_id
        snake_case__    							=				kwargs.pop("sep_token_id"   ,					__SCREAMING_SNAKE_CASE     )
        snake_case__    							=				tokenizer.sep_token_id if sep_token_id is None else sep_token_id
        snake_case__    							=				kwargs.pop("pad_token_id"   ,					__SCREAMING_SNAKE_CASE     )
        snake_case__    							=				tokenizer.pad_token_id if pad_token_id is None else pad_token_id

        snake_case__    							=				tokenizer.get_vocab()
        snake_case__    							=				sorted([(wordpiece, idx) for wordpiece, idx in vocab.items()]   ,					key=lambda __SCREAMING_SNAKE_CASE     : x[1]     )
        snake_case__    							=				[entry[0] for entry in vocab]
        return cls(
            vocab_list=__SCREAMING_SNAKE_CASE   ,					do_lower_case=__SCREAMING_SNAKE_CASE   ,					cls_token_id=__SCREAMING_SNAKE_CASE   ,					sep_token_id=__SCREAMING_SNAKE_CASE   ,					pad_token_id=__SCREAMING_SNAKE_CASE   ,					**__SCREAMING_SNAKE_CASE   ,					)

       @classmethod
       def 		_SCREAMING_SNAKE_CASE(			cls   ,					__SCREAMING_SNAKE_CASE   ,					*__SCREAMING_SNAKE_CASE   ,					**__SCREAMING_SNAKE_CASE     ):






        '''simple docstring'''

        try:
         snake_case__    							=				BertTokenizer.from_pretrained(__SCREAMING_SNAKE_CASE   ,					*__SCREAMING_SNAKE_CASE   ,					**__SCREAMING_SNAKE_CASE     )
        except:  # noqa: E722
         from .tokenization_bert_fast import BertTokenizerFast

         snake_case__    							=				BertTokenizerFast.from_pretrained(__SCREAMING_SNAKE_CASE   ,					*__SCREAMING_SNAKE_CASE   ,					**__SCREAMING_SNAKE_CASE     )
        return cls.from_tokenizer(__SCREAMING_SNAKE_CASE   ,					**__SCREAMING_SNAKE_CASE     )

       def 		_SCREAMING_SNAKE_CASE(			self   ,					__SCREAMING_SNAKE_CASE     ):






        '''simple docstring'''

        if self.do_lower_case:
         snake_case__    							=				case_fold_utfa(__SCREAMING_SNAKE_CASE     )
        snake_case__    							=				self.tf_tokenizer.tokenize(__SCREAMING_SNAKE_CASE     )
        return tokens.merge_dims(1   ,					-1     )

       def 		_SCREAMING_SNAKE_CASE(			self   ,					__SCREAMING_SNAKE_CASE   ,					__SCREAMING_SNAKE_CASE=None   ,					__SCREAMING_SNAKE_CASE=None   ,					__SCREAMING_SNAKE_CASE=None   ,					__SCREAMING_SNAKE_CASE=None   ,					__SCREAMING_SNAKE_CASE=None   ,					__SCREAMING_SNAKE_CASE=None   ,					__SCREAMING_SNAKE_CASE=None   ,					):






        '''simple docstring'''

        if padding is None:
         snake_case__    							=				self.padding
        if padding not in ("longest", "max_length"):
         raise ValueError("Padding must be either \'longest\' or \'max_length\'!"     )
        if max_length is not None and text_pair is not None:
         # Because we have to instantiate a Trimmer to do it properly
         raise ValueError("max_length cannot be overridden at call time when truncating paired texts!"     )
        if max_length is None:
         snake_case__    							=				self.max_length
        if truncation is None:
         snake_case__    							=				self.truncation
        if pad_to_multiple_of is None:
         snake_case__    							=				self.pad_to_multiple_of
        if return_token_type_ids is None:
         snake_case__    							=				self.return_token_type_ids
        if return_attention_mask is None:
         snake_case__    							=				self.return_attention_mask
        if not isinstance(__SCREAMING_SNAKE_CASE   ,					tf.Tensor     ):
         snake_case__    							=				tf.convert_to_tensor(__SCREAMING_SNAKE_CASE     )
        if text_pair is not None and not isinstance(__SCREAMING_SNAKE_CASE   ,					tf.Tensor     ):
         snake_case__    							=				tf.convert_to_tensor(__SCREAMING_SNAKE_CASE     )
        if text_pair is not None:
         if text.shape.rank > 1:
          raise ValueError("text argument should not be multidimensional when a text pair is supplied!"     )
         if text_pair.shape.rank > 1:
          raise ValueError("text_pair should not be multidimensional!"     )
        if text.shape.rank == 2:
         snake_case__    							=				text[:, 0], text[:, 1]
        snake_case__    							=				self.unpaired_tokenize(__SCREAMING_SNAKE_CASE     )
        if text_pair is None:  # Unpaired text
         if truncation:
          snake_case__    							=				text[:, : max_length - 2]  # Allow room for special tokens
         snake_case__    							=				combine_segments(
             (text,)   ,					start_of_sequence_id=self.cls_token_id   ,					end_of_segment_id=self.sep_token_id     )
        else:  # Paired text
         snake_case__    							=				self.unpaired_tokenize(__SCREAMING_SNAKE_CASE     )
         if truncation:
          snake_case__    							=				self.paired_trimmer.trim([text, text_pair]     )
         snake_case__    							=				combine_segments(
             (text, text_pair)   ,					start_of_sequence_id=self.cls_token_id   ,					end_of_segment_id=self.sep_token_id     )
        if padding == "longest":
         snake_case__    							=				input_ids.bounding_shape(axis=1     )
         if pad_to_multiple_of is not None:
          # No ceiling division in tensorflow, so we negate floordiv instead
          snake_case__    							=				pad_to_multiple_of * (-tf.math.floordiv(-pad_length   ,					__SCREAMING_SNAKE_CASE     ))
        else:
         snake_case__    							=				max_length

        snake_case__    							=				pad_model_inputs(__SCREAMING_SNAKE_CASE   ,					max_seq_length=__SCREAMING_SNAKE_CASE   ,					pad_value=self.pad_token_id     )
        snake_case__    							=				{'''input_ids''': input_ids}
        if return_attention_mask:
         snake_case__    							=				attention_mask
        if return_token_type_ids:
         snake_case__    							=				pad_model_inputs(
             __SCREAMING_SNAKE_CASE   ,					max_seq_length=__SCREAMING_SNAKE_CASE   ,					pad_value=self.pad_token_id     )
         snake_case__    							=				token_type_ids
        return output

       def 		_SCREAMING_SNAKE_CASE(			self     ):






        '''simple docstring'''

        return {
            "vocab_list": self.vocab_list,
            "do_lower_case": self.do_lower_case,
            "cls_token_id": self.cls_token_id,
            "sep_token_id": self.sep_token_id,
            "pad_token_id": self.pad_token_id,
        }








"""simple docstring"""


from math import sqrt





def 							a__			(  _UpperCAmelCase	)    ->  list[int]:

 '''simple docstring'''






 snake_case__    							=				[1]
 for i in range(2	,     int(sqrt(_UpperCAmelCase	)	) + 1	,     1	):
  if number % i == 0:
   values.append(_UpperCAmelCase	)
   if int(number // i	) != i:
    values.append(int(number // i	)	)
 return sorted(_UpperCAmelCase	)





def 							a__			(  _UpperCAmelCase	)    ->  bool:

 '''simple docstring'''






 return sum(factors(_UpperCAmelCase	)	) > n





def 							a__			(  _UpperCAmelCase	)    ->  bool:

 '''simple docstring'''






 snake_case__    							=				factors(_UpperCAmelCase	)
 snake_case__    							=				len(_UpperCAmelCase	)
 snake_case__    							=				[[0 for i in range(number + 1	)] for j in range(r + 1	)]
 for i in range(r + 1	):
  snake_case__    							=				True

 for i in range(1	,     number + 1	):
  snake_case__    							=				False

 for i in range(1	,     r + 1	):
  for j in range(1	,     number + 1	):
   if j < values[i - 1]:
    snake_case__    							=				subset[i - 1][j]
   else:
    snake_case__    							=				subset[i - 1][j] or subset[i - 1][j - values[i - 1]]

 return subset[r][number] != 0





def 							a__			(  _UpperCAmelCase	)    ->  bool:

 '''simple docstring'''






 return abundant(_UpperCAmelCase	) and not semi_perfect(_UpperCAmelCase	)


if __name__ == "__main__":
   import doctest

   doctest.testmod(verbose=True)
   for number in (6_9, 7_0, 7_1):
      print(f'''{number} is {'' if weird(number) else 'not '}weird.''')

