

import unittest

from transformers import load_tool

from .test_tools_common import ToolTesterMixin


lowerCAmelCase       :				int         =					'\nHugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf originally as a company that developed a chatbot app targeted at teenagers.[2] After open-sourcing the model behind the chatbot, the company pivoted to focus on being a platform for machine learning.\n\nIn March 2021, Hugging Face raised $40 million in a Series B funding round.[3]\n\nOn April 28, 2021, the company launched the BigScience Research Workshop in collaboration with several other research groups to release an open large language model.[4] In 2022, the workshop concluded with the announcement of BLOOM, a multilingual large language model with 176 billion parameters.[5]\n'
class 	_A						(					unittest.TestCase				,       __magic_name__):

  def 	UpperCAmelCase      (			self   ):





        """simple docstring"""







        SCREAMING_SNAKE_CASE_			:					List[str]          =       load_tool('summarization'   )
        self.tool.setup()
        SCREAMING_SNAKE_CASE_			:					Optional[Any]          =       load_tool('summarization'	,   remote=_SCREAMING_SNAKE_CASE   )

  def 	UpperCAmelCase      (			self   ):





        """simple docstring"""







        SCREAMING_SNAKE_CASE_			:					Any          =       self.tool(_SCREAMING_SNAKE_CASE   )
        self.assertEqual(
            _SCREAMING_SNAKE_CASE	,   'Hugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf. In March 2021, Hugging Face raised $40 million in a Series B funding round. On April 28, 2021, the company launched the BigScience Research Workshop in collaboration with several other research groups to release an open large language model. In 2022, the workshop concluded with the announcement of BLOOM.'	,   )

  def 	UpperCAmelCase      (			self   ):





        """simple docstring"""







        SCREAMING_SNAKE_CASE_			:					Tuple          =       self.remote_tool(_SCREAMING_SNAKE_CASE   )
        self.assertEqual(
            _SCREAMING_SNAKE_CASE	,   'Hugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf. In March 2021, Hugging Face raised $40 million in a Series B funding round. On April 28, 2021, the company launched the BigScience Research Workshop in collaboration with several other research groups to release an open large language model. In 2022, the workshop concluded with the announcement of BLOOM.'	,   )

  def 	UpperCAmelCase      (			self   ):





        """simple docstring"""







        SCREAMING_SNAKE_CASE_			:					Any          =       self.tool(text=_SCREAMING_SNAKE_CASE   )
        self.assertEqual(
            _SCREAMING_SNAKE_CASE	,   'Hugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf. In March 2021, Hugging Face raised $40 million in a Series B funding round. On April 28, 2021, the company launched the BigScience Research Workshop in collaboration with several other research groups to release an open large language model. In 2022, the workshop concluded with the announcement of BLOOM.'	,   )



  def 	UpperCAmelCase      (			self   ):





        """simple docstring"""







        SCREAMING_SNAKE_CASE_			:					Tuple          =       self.remote_tool(text=_SCREAMING_SNAKE_CASE   )
        self.assertEqual(
            _SCREAMING_SNAKE_CASE	,   'Hugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf. In March 2021, Hugging Face raised $40 million in a Series B funding round. On April 28, 2021, the company launched the BigScience Research Workshop in collaboration with several other research groups to release an open large language model. In 2022, the workshop concluded with the announcement of BLOOM.'	,   )









import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils import AddedToken
from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_mpnet import MPNetTokenizer


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

lowerCAmelCase       :				Any         =					{'vocab_file': 'vocab.txt', 'tokenizer_file': 'tokenizer.json'}

lowerCAmelCase       :				Any         =					{
    'vocab_file': {
        'microsoft/mpnet-base': 'https://huggingface.co/microsoft/mpnet-base/resolve/main/vocab.txt',
    },
    'tokenizer_file': {
        'microsoft/mpnet-base': 'https://huggingface.co/microsoft/mpnet-base/resolve/main/tokenizer.json',
    },
}

lowerCAmelCase       :				str         =					{
    'microsoft/mpnet-base': 5_12,
}

lowerCAmelCase       :				Optional[Any]         =					{
    'microsoft/mpnet-base': {'do_lower_case': True},
}
class 	_A						(					__magic_name__):
  SCREAMING_SNAKE_CASE      : Tuple    =					VOCAB_FILES_NAMES
  SCREAMING_SNAKE_CASE      : List[Any]    =					PRETRAINED_VOCAB_FILES_MAP
  SCREAMING_SNAKE_CASE      : Dict    =					PRETRAINED_INIT_CONFIGURATION
  SCREAMING_SNAKE_CASE      : str    =					PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
  SCREAMING_SNAKE_CASE      : Dict    =					MPNetTokenizer
  SCREAMING_SNAKE_CASE      : Any    =					['''input_ids''', '''attention_mask''']

  def __init__(			self	,   _SCREAMING_SNAKE_CASE=None	,   _SCREAMING_SNAKE_CASE=None	,   _SCREAMING_SNAKE_CASE=True	,   _SCREAMING_SNAKE_CASE="<s>"	,   _SCREAMING_SNAKE_CASE="</s>"	,   _SCREAMING_SNAKE_CASE="</s>"	,   _SCREAMING_SNAKE_CASE="<s>"	,   _SCREAMING_SNAKE_CASE="[UNK]"	,   _SCREAMING_SNAKE_CASE="<pad>"	,   _SCREAMING_SNAKE_CASE="<mask>"	,   _SCREAMING_SNAKE_CASE=True	,   _SCREAMING_SNAKE_CASE=None	,   **_SCREAMING_SNAKE_CASE	,   ):





        """simple docstring"""







        super().__init__(
            _SCREAMING_SNAKE_CASE	,   tokenizer_file=_SCREAMING_SNAKE_CASE	,   do_lower_case=_SCREAMING_SNAKE_CASE	,   bos_token=_SCREAMING_SNAKE_CASE	,   eos_token=_SCREAMING_SNAKE_CASE	,   sep_token=_SCREAMING_SNAKE_CASE	,   cls_token=_SCREAMING_SNAKE_CASE	,   unk_token=_SCREAMING_SNAKE_CASE	,   pad_token=_SCREAMING_SNAKE_CASE	,   mask_token=_SCREAMING_SNAKE_CASE	,   tokenize_chinese_chars=_SCREAMING_SNAKE_CASE	,   strip_accents=_SCREAMING_SNAKE_CASE	,   **_SCREAMING_SNAKE_CASE	,   )

        SCREAMING_SNAKE_CASE_			:					Optional[Any]          =       json.loads(self.backend_tokenizer.normalizer.__getstate__()   )
        if (
            pre_tok_state.get('lowercase'	,   _SCREAMING_SNAKE_CASE   ) != do_lower_case
            or pre_tok_state.get('strip_accents'	,   _SCREAMING_SNAKE_CASE   ) != strip_accents
        ):
              SCREAMING_SNAKE_CASE_			:					Any          =       getattr(_SCREAMING_SNAKE_CASE	,   pre_tok_state.pop('type'   )   )
              SCREAMING_SNAKE_CASE_			:					Dict          =       do_lower_case
              SCREAMING_SNAKE_CASE_			:					Union[str, Any]          =       strip_accents
              SCREAMING_SNAKE_CASE_			:					Tuple          =       pre_tok_class(**_SCREAMING_SNAKE_CASE   )

        SCREAMING_SNAKE_CASE_			:					Optional[Any]          =       do_lower_case

  @property
  def 	UpperCAmelCase      (			self   ):





        """simple docstring"""







        if self._mask_token is None:
              if self.verbose:
                    logger.error('Using mask_token, but it is not set yet.'   )
              return None
        return str(self._mask_token   )

  @mask_token.setter
  def 	UpperCAmelCase      (			self	,   _SCREAMING_SNAKE_CASE   ):





        """simple docstring"""







        SCREAMING_SNAKE_CASE_			:					Optional[Any]          =       AddedToken(_SCREAMING_SNAKE_CASE	,   lstrip=_SCREAMING_SNAKE_CASE	,   rstrip=_SCREAMING_SNAKE_CASE   ) if isinstance(_SCREAMING_SNAKE_CASE	,   _SCREAMING_SNAKE_CASE   ) else value
        SCREAMING_SNAKE_CASE_			:					List[Any]          =       value

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





        """simple docstring"""







        SCREAMING_SNAKE_CASE_			:					List[str]          =       [self.bos_token_id] + token_ids_a + [self.eos_token_id]
        if token_ids_a is None:
              return output

        return output + [self.eos_token_id] + token_ids_a + [self.eos_token_id]

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





        """simple docstring"""







        SCREAMING_SNAKE_CASE_			:					str          =       [self.sep_token_id]
        SCREAMING_SNAKE_CASE_			:					int          =       [self.cls_token_id]

        if token_ids_a is None:
              return len(cls + token_ids_a + sep   ) * [0]
        return len(cls + token_ids_a + sep + sep + token_ids_a + sep   ) * [0]



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





        """simple docstring"""







        SCREAMING_SNAKE_CASE_			:					Tuple          =       self._tokenizer.model.save(_SCREAMING_SNAKE_CASE	,   name=_SCREAMING_SNAKE_CASE   )
        return tuple(_SCREAMING_SNAKE_CASE   )






