



from ...configuration_utils import PretrainedConfig
from ...utils import logging


_lowerCamelCase						    =  logging.get_logger(__name__)

_lowerCamelCase						    =  {
    """google/realm-cc-news-pretrained-embedder""": (
        """https://huggingface.co/google/realm-cc-news-pretrained-embedder/resolve/main/config.json"""
    ),
    """google/realm-cc-news-pretrained-encoder""": (
        """https://huggingface.co/google/realm-cc-news-pretrained-encoder/resolve/main/config.json"""
    ),
    """google/realm-cc-news-pretrained-scorer""": (
        """https://huggingface.co/google/realm-cc-news-pretrained-scorer/resolve/main/config.json"""
    ),
    """google/realm-cc-news-pretrained-openqa""": (
        """https://huggingface.co/google/realm-cc-news-pretrained-openqa/aresolve/main/config.json"""
    ),
    """google/realm-orqa-nq-openqa""": """https://huggingface.co/google/realm-orqa-nq-openqa/resolve/main/config.json""",
    """google/realm-orqa-nq-reader""": """https://huggingface.co/google/realm-orqa-nq-reader/resolve/main/config.json""",
    """google/realm-orqa-wq-openqa""": """https://huggingface.co/google/realm-orqa-wq-openqa/resolve/main/config.json""",
    """google/realm-orqa-wq-reader""": """https://huggingface.co/google/realm-orqa-wq-reader/resolve/main/config.json""",
    # See all REALM models at https://huggingface.co/models?filter=realm
}

class       _SCREAMING_SNAKE_CASE	(UpperCamelCase ):
     lowerCAmelCase					=			"""realm"""





     def __init__(       self :							Union[str, Any]     ,  UpperCamelCase :							int=3_0_5_2_2     ,  UpperCamelCase :							Tuple=7_6_8     ,  UpperCamelCase :							str=1_2_8     ,  UpperCamelCase :							Dict=1_2     ,  UpperCamelCase :							List[str]=1_2     ,  UpperCamelCase :							Tuple=8     ,  UpperCamelCase :							Dict=3_0_7_2     ,  UpperCamelCase :							Dict="gelu_new"     ,  UpperCamelCase :							Union[str, Any]=0.1     ,  UpperCamelCase :							str=0.1     ,  UpperCamelCase :							Dict=5_1_2     ,  UpperCamelCase :							Any=2     ,  UpperCamelCase :							str=0.0_2     ,  UpperCamelCase :							List[str]=1E-12     ,  UpperCamelCase :							Optional[Any]=2_5_6     ,  UpperCamelCase :							Optional[int]=1_0     ,  UpperCamelCase :							int=1E-3     ,  UpperCamelCase :							str=5     ,  UpperCamelCase :							int=3_2_0     ,  UpperCamelCase :							Optional[Any]=1_3_3_5_3_7_1_8     ,  UpperCamelCase :							Optional[int]=5_0_0_0     ,  UpperCamelCase :							str=1     ,  UpperCamelCase :							Tuple=0     ,  UpperCamelCase :							List[str]=2     ,  **UpperCamelCase :							Optional[Any]     ,  )->List[Any]:
      super().__init__(pad_token_id=UpperCamelCase     ,  bos_token_id=UpperCamelCase     ,  eos_token_id=UpperCamelCase     ,  **UpperCamelCase				)

      # Common config
      __SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	vocab_size
      __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	max_position_embeddings
      __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	hidden_size
      __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	retriever_proj_size
      __SCREAMING_SNAKE_CASE       :    Dict       =	num_hidden_layers
      __SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	num_attention_heads
      __SCREAMING_SNAKE_CASE       :    Dict       =	num_candidates
      __SCREAMING_SNAKE_CASE       :    int       =	intermediate_size
      __SCREAMING_SNAKE_CASE       :    List[Any]       =	hidden_act
      __SCREAMING_SNAKE_CASE       :    Any       =	hidden_dropout_prob
      __SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	attention_probs_dropout_prob
      __SCREAMING_SNAKE_CASE       :    List[Any]       =	initializer_range
      __SCREAMING_SNAKE_CASE       :    Tuple       =	type_vocab_size
      __SCREAMING_SNAKE_CASE       :    List[Any]       =	layer_norm_eps

      # Reader config
      __SCREAMING_SNAKE_CASE       :    str       =	span_hidden_size
      __SCREAMING_SNAKE_CASE       :    Any       =	max_span_width
      __SCREAMING_SNAKE_CASE       :    Any       =	reader_layer_norm_eps
      __SCREAMING_SNAKE_CASE       :    Dict       =	reader_beam_size
      __SCREAMING_SNAKE_CASE       :    List[Any]       =	reader_seq_len

      # Retrieval config
      __SCREAMING_SNAKE_CASE       :    Dict       =	num_block_records
      __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	searcher_beam_size











# 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				)






