





import json
import os
from typing import Optional, Tuple

from ...tokenization_utils import PreTrainedTokenizer
from ...utils import logging


lowerCAmelCase     :   Optional[Any]						     =  logging.get_logger(__name__)

lowerCAmelCase     :   Any						     =  {'vocab_file': 'vocab.json'}

lowerCAmelCase     :   List[Any]						     =  {
    'vocab_file': {
        'mgp-str': 'https://huggingface.co/alibaba-damo/mgp-str-base/blob/main/vocab.json',
    }
}

lowerCAmelCase     :   str						     =  {'mgp-str': 27}
class  _A		(  _UpperCamelCase):
  SCREAMING_SNAKE_CASE    :      Optional[Any]       =  VOCAB_FILES_NAMES
  SCREAMING_SNAKE_CASE    :      List[str]       =  PRETRAINED_VOCAB_FILES_MAP
  SCREAMING_SNAKE_CASE    :      int       =  PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES

  def __init__(				self ,					_SCREAMING_SNAKE_CASE ,					_SCREAMING_SNAKE_CASE="[GO]" ,					_SCREAMING_SNAKE_CASE="[GO]" ,					_SCREAMING_SNAKE_CASE="[s]" ,					_SCREAMING_SNAKE_CASE="[GO]" ,					**_SCREAMING_SNAKE_CASE					):





        """simple docstring"""







        super().__init__(
            unk_token=_UpperCAmelCase ,					bos_token=_UpperCAmelCase ,					eos_token=_UpperCAmelCase ,					pad_token=_UpperCAmelCase ,					**_UpperCAmelCase ,					)

        with open(_UpperCAmelCase ,					encoding='utf-8'					) as vocab_handle:
              SCREAMING_SNAKE_CASE_				:  Tuple           =     json.load(_UpperCAmelCase					)
        SCREAMING_SNAKE_CASE_				:  Optional[int]           =     {v: k for k, v in self.vocab.items()}

  @property
  def  UpperCAmelCase    (				self					):





        """simple docstring"""







        return len(self.vocab					)

  def  UpperCAmelCase    (				self					):





        """simple docstring"""







        return dict(self.vocab ,					**self.added_tokens_encoder					)

  def  UpperCAmelCase    (				self ,					_SCREAMING_SNAKE_CASE					):





        """simple docstring"""







        SCREAMING_SNAKE_CASE_				:  str           =     []
        for s in text:
              char_tokens.extend(_UpperCAmelCase					)
        return char_tokens

  def  UpperCAmelCase    (				self ,					_SCREAMING_SNAKE_CASE					):





        """simple docstring"""







        return self.vocab.get(_UpperCAmelCase ,					self.vocab.get(self.unk_token					)					)

  def  UpperCAmelCase    (				self ,					_SCREAMING_SNAKE_CASE					):





        """simple docstring"""







        return self.decoder.get(_UpperCAmelCase					)



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





        """simple docstring"""







        if not os.path.isdir(_UpperCAmelCase					):
              logger.error('Vocabulary path ({}) should be a directory'.format(_UpperCAmelCase					)					)
              return
        SCREAMING_SNAKE_CASE_				:  Optional[Any]           =     os.path.join(
            _UpperCAmelCase ,					(filename_prefix + '-' if filename_prefix else '') + VOCAB_FILES_NAMES['vocab_file']					)

        with open(_UpperCAmelCase ,					'w' ,					encoding='utf-8'					) as f:
              f.write(json.dumps(self.vocab ,					indent=2 ,					sort_keys=_UpperCAmelCase ,					ensure_ascii=_UpperCAmelCase					) + '\n'					)

        return (vocab_file,)









def    A_  (							a					,   a  ):

      """simple docstring"""



      return int((input_a, input_a).count(0  ) != 0  )

def    A_  (							):

      """simple docstring"""



      assert nand_gate(0					,   0  ) == 1
      assert nand_gate(0					,   1  ) == 1
      assert nand_gate(1					,   0  ) == 1
      assert nand_gate(1					,   1  ) == 0


if __name__ == "__main__":
    print(nand_gate(0, 0))
    print(nand_gate(0, 1))
    print(nand_gate(1, 0))
    print(nand_gate(1, 1))






