



import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_convbert import ConvBertTokenizer


_lowerCamelCase						    =  logging.get_logger(__name__)

_lowerCamelCase						    =  {"""vocab_file""": """vocab.txt"""}

_lowerCamelCase						    =  {
    """vocab_file""": {
        """YituTech/conv-bert-base""": """https://huggingface.co/YituTech/conv-bert-base/resolve/main/vocab.txt""",
        """YituTech/conv-bert-medium-small""": (
            """https://huggingface.co/YituTech/conv-bert-medium-small/resolve/main/vocab.txt"""
        ),
        """YituTech/conv-bert-small""": """https://huggingface.co/YituTech/conv-bert-small/resolve/main/vocab.txt""",
    }
}

_lowerCamelCase						    =  {
    """YituTech/conv-bert-base""": 512,
    """YituTech/conv-bert-medium-small""": 512,
    """YituTech/conv-bert-small""": 512,
}


_lowerCamelCase						    =  {
    """YituTech/conv-bert-base""": {"""do_lower_case""": True},
    """YituTech/conv-bert-medium-small""": {"""do_lower_case""": True},
    """YituTech/conv-bert-small""": {"""do_lower_case""": True},
}

class       _SCREAMING_SNAKE_CASE	(UpperCamelCase ):
     lowerCAmelCase					=			VOCAB_FILES_NAMES
     lowerCAmelCase					=			PRETRAINED_VOCAB_FILES_MAP
     lowerCAmelCase					=			PRETRAINED_INIT_CONFIGURATION
     lowerCAmelCase					=			PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
     lowerCAmelCase					=			ConvBertTokenizer





     def __init__(       self :							Any     ,  UpperCamelCase :							int=None     ,  UpperCamelCase :							Union[str, Any]=None     ,  UpperCamelCase :							List[Any]=True     ,  UpperCamelCase :							Optional[Any]="[UNK]"     ,  UpperCamelCase :							Optional[Any]="[SEP]"     ,  UpperCamelCase :							int="[PAD]"     ,  UpperCamelCase :							Any="[CLS]"     ,  UpperCamelCase :							List[str]="[MASK]"     ,  UpperCamelCase :							Optional[Any]=True     ,  UpperCamelCase :							Optional[int]=None     ,  **UpperCamelCase :							Optional[Any]     ,  )->Dict:
      super().__init__(
          UpperCamelCase     ,  tokenizer_file=UpperCamelCase     ,  do_lower_case=UpperCamelCase     ,  unk_token=UpperCamelCase     ,  sep_token=UpperCamelCase     ,  pad_token=UpperCamelCase     ,  cls_token=UpperCamelCase     ,  mask_token=UpperCamelCase     ,  tokenize_chinese_chars=UpperCamelCase     ,  strip_accents=UpperCamelCase     ,  **UpperCamelCase     ,  )

      __SCREAMING_SNAKE_CASE       :    str       =	json.loads(self.backend_tokenizer.normalizer.__getstate__()				)
      if (
          normalizer_state.get("lowercase"     ,  UpperCamelCase				) != do_lower_case
          or normalizer_state.get("strip_accents"     ,  UpperCamelCase				) != strip_accents
          or normalizer_state.get("handle_chinese_chars"     ,  UpperCamelCase				) != tokenize_chinese_chars
      ):
       __SCREAMING_SNAKE_CASE       :    str       =	getattr(UpperCamelCase     ,  normalizer_state.pop("type"				)				)
       __SCREAMING_SNAKE_CASE       :    Optional[int]       =	do_lower_case
       __SCREAMING_SNAKE_CASE       :    Tuple       =	strip_accents
       __SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	tokenize_chinese_chars
       __SCREAMING_SNAKE_CASE       :    List[str]       =	normalizer_class(**UpperCamelCase				)

      __SCREAMING_SNAKE_CASE       :    Optional[int]       =	do_lower_case





     def 	__snake_case    (       self :							List[str]     ,  UpperCamelCase :							Any     ,  UpperCamelCase :							List[str]=None				)->str:
      __SCREAMING_SNAKE_CASE       :    List[str]       =	[self.cls_token_id] + token_ids_a + [self.sep_token_id]

      if token_ids_a:
       output += token_ids_a + [self.sep_token_id]

      return output





     def 	__snake_case    (       self :							Tuple     ,  UpperCamelCase :							List[int]     ,  UpperCamelCase :							Optional[List[int]] = None				)->List[int]:
      __SCREAMING_SNAKE_CASE       :    Tuple       =	[self.sep_token_id]
      __SCREAMING_SNAKE_CASE       :    str       =	[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				) * [0] + len(token_ids_a + sep				) * [1]






     def 	__snake_case    (       self :							Union[str, Any]     ,  UpperCamelCase :							str     ,  UpperCamelCase :							Optional[str] = None				)->Tuple[str]:
      __SCREAMING_SNAKE_CASE       :    Dict       =	self._tokenizer.model.save(UpperCamelCase     ,  name=UpperCamelCase				)
      return tuple(UpperCamelCase				)











# Copyright 2023 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from ..models.auto import AutoModelForSeqaSeqLM, AutoTokenizer
from .base import PipelineTool

class       _SCREAMING_SNAKE_CASE	(UpperCamelCase ):
     lowerCAmelCase					=			"""philschmid/bart-large-cnn-samsum"""
     lowerCAmelCase					=			(
         """This is a tool that summarizes an English text. It takes an input `text` containing the text to summarize, """
         """and returns a summary of the text."""
     )
     lowerCAmelCase					=			"""summarizer"""
     lowerCAmelCase					=			AutoTokenizer
     lowerCAmelCase					=			AutoModelForSeqaSeqLM

     lowerCAmelCase					=			["""text"""]
     lowerCAmelCase					=			["""text"""]





     def 	__snake_case    (       self :							Union[str, Any]     ,  UpperCamelCase :							Tuple				)->Tuple:
      return self.pre_processor(UpperCamelCase     ,  return_tensors="pt"     ,  truncation=UpperCamelCase				)





     def 	__snake_case    (       self :							Dict     ,  UpperCamelCase :							List[Any]				)->Optional[Any]:
      return self.model.generate(**UpperCamelCase				)[0]






     def 	__snake_case    (       self :							Tuple     ,  UpperCamelCase :							Dict				)->Optional[int]:
      return self.pre_processor.decode(UpperCamelCase     ,  skip_special_tokens=UpperCamelCase     ,  clean_up_tokenization_spaces=UpperCamelCase				)






