

"""simple docstring"""


# 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      __a							(UpperCamelCase_):






     '''simple docstring'''
     _SCREAMING_SNAKE_CASE						:int       = """philschmid/bart-large-cnn-samsum"""
     _SCREAMING_SNAKE_CASE						:Dict       = (
         """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."""
     )
     _SCREAMING_SNAKE_CASE						:Any       = """summarizer"""
     _SCREAMING_SNAKE_CASE						:str       = AutoTokenizer
     _SCREAMING_SNAKE_CASE						:str       = AutoModelForSeqaSeqLM

     _SCREAMING_SNAKE_CASE						:str       = ["""text"""]
     _SCREAMING_SNAKE_CASE						:str       = ["""text"""]

     def 					_a			(						self	,    _a  )  ->      str:


           """simple docstring"""


           return self.pre_processor(_a	,    return_tensors="""pt"""	,    truncation=_a  )

     def 					_a			(						self	,    _a  )  ->      Any:


           """simple docstring"""


           return self.model.generate(**_a  )[0]





     def 					_a			(						self	,    _a  )  ->      int:


           """simple docstring"""


           return self.pre_processor.decode(_a	,    skip_special_tokens=_a	,    clean_up_tokenization_spaces=_a  )







"""simple docstring"""


import os
from shutil import copyfile
from typing import List, Optional, Tuple

from ...tokenization_utils import AddedToken
from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import is_sentencepiece_available, logging


if is_sentencepiece_available():
  from .tokenization_xlnet import XLNetTokenizer
else:
  a					:List[Any]    = None


a					:Optional[int]    = logging.get_logger(__name__)

a					:Union[str, Any]    = {"vocab_file": "spiece.model", "tokenizer_file": "tokenizer.json"}

a					:Optional[int]    = {
    "vocab_file": {
        "xlnet-base-cased": "https://huggingface.co/xlnet-base-cased/resolve/main/spiece.model",
        "xlnet-large-cased": "https://huggingface.co/xlnet-large-cased/resolve/main/spiece.model",
    },
    "tokenizer_file": {
        "xlnet-base-cased": "https://huggingface.co/xlnet-base-cased/resolve/main/tokenizer.json",
        "xlnet-large-cased": "https://huggingface.co/xlnet-large-cased/resolve/main/tokenizer.json",
    },
}

a					:Dict    = {
    "xlnet-base-cased": None,
    "xlnet-large-cased": None,
}

a					:int    = "▁"

# Segments (not really needed)
a					:Dict    = 0
a					:Optional[int]    = 1
a					:Tuple    = 2
a					:List[str]    = 3
a					:Optional[Any]    = 4

class      __a							(UpperCamelCase_):






     '''simple docstring'''
     _SCREAMING_SNAKE_CASE						:Tuple       = VOCAB_FILES_NAMES
     _SCREAMING_SNAKE_CASE						:Union[str, Any]       = PRETRAINED_VOCAB_FILES_MAP
     _SCREAMING_SNAKE_CASE						:Tuple       = PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
     _SCREAMING_SNAKE_CASE						:str       = """left"""
     _SCREAMING_SNAKE_CASE						:Optional[Any]       = XLNetTokenizer

     def __init__(						self	,    _a=None	,    _a=None	,    _a=False	,    _a=True	,    _a=False	,    _a="<s>"	,    _a="</s>"	,    _a="<unk>"	,    _a="<sep>"	,    _a="<pad>"	,    _a="<cls>"	,    _a="<mask>"	,    _a=["<eop>", "<eod>"]	,    **_a	,    )  ->      Any:


           """simple docstring"""


           SCREAMING_SNAKE_CASE__   :      Tuple      		=	AddedToken(_a	,    lstrip=_a	,    rstrip=_a  ) if isinstance(_a	,    _a  ) else mask_token

           super().__init__(
               vocab_file=_a	,    tokenizer_file=_a	,    do_lower_case=_a	,    remove_space=_a	,    keep_accents=_a	,    bos_token=_a	,    eos_token=_a	,    unk_token=_a	,    sep_token=_a	,    pad_token=_a	,    cls_token=_a	,    mask_token=_a	,    additional_special_tokens=_a	,    **_a	,    )

           SCREAMING_SNAKE_CASE__   :      Union[str, Any]      		=	3
           SCREAMING_SNAKE_CASE__   :      Optional[int]      		=	do_lower_case
           SCREAMING_SNAKE_CASE__   :      List[str]      		=	remove_space
           SCREAMING_SNAKE_CASE__   :      int      		=	keep_accents
           SCREAMING_SNAKE_CASE__   :      Optional[Any]      		=	vocab_file
           SCREAMING_SNAKE_CASE__   :      Tuple      		=	False if not self.vocab_file else True

     def 					_a			(						self	,    _a	,    _a = None  )  ->      List[int]:


           """simple docstring"""


           SCREAMING_SNAKE_CASE__   :      str      		=	[self.sep_token_id]
           SCREAMING_SNAKE_CASE__   :      Tuple      		=	[self.cls_token_id]
           if token_ids_a is None:
                 return token_ids_a + sep + cls
           return token_ids_a + sep + token_ids_a + sep + cls

     def 					_a			(						self	,    _a	,    _a = None  )  ->      List[int]:


           """simple docstring"""


           SCREAMING_SNAKE_CASE__   :      Any      		=	[self.sep_token_id]
           SCREAMING_SNAKE_CASE__   :      Optional[Any]      		=	[2]

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





     def 					_a			(						self	,    _a	,    _a = None  )  ->      Tuple[str]:


           """simple docstring"""


           if not self.can_save_slow_tokenizer:
                 raise ValueError(
                     """Your fast tokenizer does not have the necessary information to save the vocabulary for a slow """
                     """tokenizer."""  )

           if not os.path.isdir(_a  ):
                 logger.error(f'''Vocabulary path ({save_directory}) should be a directory'''  )
                 return
           SCREAMING_SNAKE_CASE__   :      Tuple      		=	os.path.join(
               _a	,    (filename_prefix + """-""" if filename_prefix else """""") + VOCAB_FILES_NAMES["""vocab_file"""]  )

           if os.path.abspath(self.vocab_file  ) != os.path.abspath(_a  ):
                 copyfile(self.vocab_file	,    _a  )

           return (out_vocab_file,)




