

'''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 		lowerCAmelCase__     (   tf.keras.layers.Layer      ):



 """simple docstring"""



 def __init__(	self      : Tuple      ,							__SCREAMING_SNAKE_CASE      : List      ,							__SCREAMING_SNAKE_CASE      : bool      ,							__SCREAMING_SNAKE_CASE      : int = None      ,							__SCREAMING_SNAKE_CASE      : int = None      ,							__SCREAMING_SNAKE_CASE      : int = None      ,							__SCREAMING_SNAKE_CASE      : str = "longest"      ,							__SCREAMING_SNAKE_CASE      : bool = True      ,							__SCREAMING_SNAKE_CASE      : int = 512      ,							__SCREAMING_SNAKE_CASE      : int = None      ,							__SCREAMING_SNAKE_CASE      : bool = True      ,							__SCREAMING_SNAKE_CASE      : bool = True      ,							__SCREAMING_SNAKE_CASE      : bool = True      ,							**__SCREAMING_SNAKE_CASE      : str      ,							)						->				List[Any]:


      """simple docstring"""




      super().__init__()
      if use_fast_bert_tokenizer:
           __SCREAMING_SNAKE_CASE						     =   FastBertTokenizer(
               __SCREAMING_SNAKE_CASE      ,							token_out_type=tf.intaa      ,							lower_case_nfd_strip_accents=__SCREAMING_SNAKE_CASE      ,							**__SCREAMING_SNAKE_CASE    )
      else:
           __SCREAMING_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      ,							)
           __SCREAMING_SNAKE_CASE						     =   BertTokenizerLayer(
               __SCREAMING_SNAKE_CASE      ,							token_out_type=tf.intaa      ,							lower_case=__SCREAMING_SNAKE_CASE      ,							**__SCREAMING_SNAKE_CASE    )

      __SCREAMING_SNAKE_CASE						     =   vocab_list
      __SCREAMING_SNAKE_CASE						     =   do_lower_case
      __SCREAMING_SNAKE_CASE						     =   cls_token_id or vocab_list.index("""[CLS]"""    )
      __SCREAMING_SNAKE_CASE						     =   sep_token_id or vocab_list.index("""[SEP]"""    )
      __SCREAMING_SNAKE_CASE						     =   pad_token_id or vocab_list.index("""[PAD]"""    )
      __SCREAMING_SNAKE_CASE						     =   ShrinkLongestTrimmer(max_length - 3      ,							axis=1    )  # Allow room for special tokens
      __SCREAMING_SNAKE_CASE						     =   max_length
      __SCREAMING_SNAKE_CASE						     =   padding
      __SCREAMING_SNAKE_CASE						     =   truncation
      __SCREAMING_SNAKE_CASE						     =   pad_to_multiple_of
      __SCREAMING_SNAKE_CASE						     =   return_token_type_ids
      __SCREAMING_SNAKE_CASE						     =   return_attention_mask
 @classmethod
 def    UpperCAmelCase__	(	cls      : Dict      ,							__SCREAMING_SNAKE_CASE      : "PreTrainedTokenizerBase"      ,							**__SCREAMING_SNAKE_CASE      : Optional[int]    )						->				Any:  # noqa: F821


      """simple docstring"""




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

      __SCREAMING_SNAKE_CASE						     =   tokenizer.get_vocab()
      __SCREAMING_SNAKE_CASE						     =   sorted([(wordpiece, idx) for wordpiece, idx in vocab.items()]      ,							key=lambda __SCREAMING_SNAKE_CASE    : x[1]    )
      __SCREAMING_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    UpperCAmelCase__	(	cls      : List[str]      ,							__SCREAMING_SNAKE_CASE      : Union[str, os.PathLike]      ,							*__SCREAMING_SNAKE_CASE      : Union[str, Any]      ,							**__SCREAMING_SNAKE_CASE      : Tuple    )						->				Optional[Any]:


      """simple docstring"""




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

           __SCREAMING_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    UpperCAmelCase__	(	self      : Optional[int]      ,							__SCREAMING_SNAKE_CASE      : Optional[int]    )						->				Optional[int]:


      """simple docstring"""




      if self.do_lower_case:
           __SCREAMING_SNAKE_CASE						     =   case_fold_utfa(__SCREAMING_SNAKE_CASE    )
      __SCREAMING_SNAKE_CASE						     =   self.tf_tokenizer.tokenize(__SCREAMING_SNAKE_CASE    )
      return tokens.merge_dims(1      ,							-1    )
 def    UpperCAmelCase__	(	self      : Optional[Any]      ,							__SCREAMING_SNAKE_CASE      : Dict      ,							__SCREAMING_SNAKE_CASE      : Optional[int]=None      ,							__SCREAMING_SNAKE_CASE      : int=None      ,							__SCREAMING_SNAKE_CASE      : Optional[Any]=None      ,							__SCREAMING_SNAKE_CASE      : Tuple=None      ,							__SCREAMING_SNAKE_CASE      : List[Any]=None      ,							__SCREAMING_SNAKE_CASE      : Union[str, Any]=None      ,							__SCREAMING_SNAKE_CASE      : str=None      ,							)						->				Dict:


      """simple docstring"""




      if padding is None:
           __SCREAMING_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:
           __SCREAMING_SNAKE_CASE						     =   self.max_length
      if truncation is None:
           __SCREAMING_SNAKE_CASE						     =   self.truncation
      if pad_to_multiple_of is None:
           __SCREAMING_SNAKE_CASE						     =   self.pad_to_multiple_of
      if return_token_type_ids is None:
           __SCREAMING_SNAKE_CASE						     =   self.return_token_type_ids
      if return_attention_mask is None:
           __SCREAMING_SNAKE_CASE						     =   self.return_attention_mask
      if not isinstance(__SCREAMING_SNAKE_CASE      ,							tf.Tensor    ):
           __SCREAMING_SNAKE_CASE						     =   tf.convert_to_tensor(__SCREAMING_SNAKE_CASE    )
      if text_pair is not None and not isinstance(__SCREAMING_SNAKE_CASE      ,							tf.Tensor    ):
           __SCREAMING_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:
           __SCREAMING_SNAKE_CASE     ,    __SCREAMING_SNAKE_CASE						     =   text[:, 0], text[:, 1]
      __SCREAMING_SNAKE_CASE						     =   self.unpaired_tokenize(__SCREAMING_SNAKE_CASE    )
      if text_pair is None:  # Unpaired text
           if truncation:
                __SCREAMING_SNAKE_CASE						     =   text[:, : max_length - 2]  # Allow room for special tokens
           __SCREAMING_SNAKE_CASE     ,    __SCREAMING_SNAKE_CASE						     =   combine_segments(
               (text,)      ,							start_of_sequence_id=self.cls_token_id      ,							end_of_segment_id=self.sep_token_id    )
      else:  # Paired text
           __SCREAMING_SNAKE_CASE						     =   self.unpaired_tokenize(__SCREAMING_SNAKE_CASE    )
           if truncation:
                __SCREAMING_SNAKE_CASE     ,    __SCREAMING_SNAKE_CASE						     =   self.paired_trimmer.trim([text, text_pair]    )
           __SCREAMING_SNAKE_CASE     ,    __SCREAMING_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":
           __SCREAMING_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
                __SCREAMING_SNAKE_CASE						     =   pad_to_multiple_of * (-tf.math.floordiv(-pad_length      ,							__SCREAMING_SNAKE_CASE    ))
      else:
           __SCREAMING_SNAKE_CASE						     =   max_length

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


 def    UpperCAmelCase__	(	self      : Tuple    )						->				List[Any]:


      """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'''



def      a__ (						):




     """simple docstring"""


     __SCREAMING_SNAKE_CASE						     =   1

     while True:
          if (
              sorted(str(a__		)		)
              == sorted(str(2 * i		)		)
              == sorted(str(3 * i		)		)
              == sorted(str(4 * i		)		)
              == sorted(str(5 * i		)		)
              == sorted(str(6 * i		)		)
          ):
               return i

          i += 1


if __name__ == "__main__":
  print(solution())






