
import doctest
import logging
import os
import unittest
from pathlib import Path
from typing import List, Union

import transformers
from transformers.testing_utils import require_tf, require_torch, slow


lowercase  :					Optional[Any]													=       logging.getLogger()




@unittest.skip('Temporarily disable the doc tests.')
@require_torch
@require_tf
@slow
class  lowerCamelCase__							(				unittest.TestCase):




	'''simple docstring'''




	def    _lowerCamelCase				(					self		:List[Any]     ,   a		:Path     ,   a		:Union[str, None] = None     ,   a		:Union[List[str], None] = None     ,   a		:Union[str, List[str], None] = None     ,   a		:bool = True     ,   )		-> Union[str, Any]:
								__UpperCamelCase	:   List[Any]			   =					[file for file in os.listdir(a						) if os.path.isfile(os.path.join(a     ,   a						)						)]

								if identifier is not None:
															__UpperCamelCase	:   List[str]			   =					[file for file in files if identifier in file]

								if n_identifier is not None:
															if isinstance(a     ,   a						):
																						for n_ in n_identifier:
																													__UpperCamelCase	:   Any			   =					[file for file in files if n_ not in file]
															else:
																						__UpperCamelCase	:   Any			   =					[file for file in files if n_identifier not in file]

								__UpperCamelCase	:   Any			   =					ignore_files or []
								ignore_files.append("__init__.py"						)
								__UpperCamelCase	:   Dict			   =					[file for file in files if file not in ignore_files]

								for file in files:
															# Open all files
															print("Testing"     ,   a						)

															if only_modules:
																						__UpperCamelCase	:   Optional[int]			   =					file.split("."						)[0]
																						try:
																													__UpperCamelCase	:   Optional[int]			   =					getattr(a     ,   a						)
																													__UpperCamelCase	:   Tuple			   =					doctest.DocTestSuite(a						)
																													__UpperCamelCase	:   Union[str, Any]			   =					unittest.TextTestRunner().run(a						)
																													self.assertIs(len(result.failures						)     ,   0						)
																						except AttributeError:
																													logger.info(f'{module_identifier} is not a module.'						)
															else:
																						__UpperCamelCase	:   int			   =					doctest.testfile(str(".." / directory / file						)     ,   optionflags=doctest.ELLIPSIS						)
																						self.assertIs(result.failed     ,   0						)







	def    _lowerCamelCase				(					self		:Dict						)		-> str:
								__UpperCamelCase	:   int			   =					Path("src/transformers"						)
								__UpperCamelCase	:   int			   =					"modeling"
								__UpperCamelCase	:   Optional[int]			   =					[
								    "modeling_ctrl.py",
								    "modeling_tf_ctrl.py",
								]
								self.analyze_directory(a     ,   identifier=a     ,   ignore_files=a						)







	def    _lowerCamelCase				(					self		:Optional[Any]						)		-> Tuple:
								__UpperCamelCase	:   str			   =					Path("src/transformers"						)
								__UpperCamelCase	:   List[Any]			   =					"tokenization"
								self.analyze_directory(a     ,   identifier=a						)







	def    _lowerCamelCase				(					self		:str						)		-> List[str]:
								__UpperCamelCase	:   Optional[int]			   =					Path("src/transformers"						)
								__UpperCamelCase	:   Optional[int]			   =					"configuration"
								self.analyze_directory(a     ,   identifier=a						)







	def    _lowerCamelCase				(					self		:Optional[int]						)		-> Optional[int]:
								__UpperCamelCase	:   Tuple			   =					Path("src/transformers"						)
								__UpperCamelCase	:   Dict			   =					["configuration", "modeling", "tokenization"]
								self.analyze_directory(a     ,   n_identifier=a						)







	def    _lowerCamelCase				(					self		:Union[str, Any]						)		-> Tuple:
								__UpperCamelCase	:   Dict			   =					Path("docs/source"						)
								__UpperCamelCase	:   List[str]			   =					["favicon.ico"]
								self.analyze_directory(a     ,   ignore_files=a     ,   only_modules=a						)

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


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

lowercase  :					Any													=       {
    'google/pegasus-large': 'https://huggingface.co/google/pegasus-large/resolve/main/config.json',
    # See all PEGASUS models at https://huggingface.co/models?filter=pegasus
}




class  lowerCamelCase__							(				__lowercase):




	'''simple docstring'''




	_A								=     'pegasus'
	_A								=     ['past_key_values']
	_A								=     {'num_attention_heads': 'encoder_attention_heads', 'hidden_size': 'd_model'}







	def __init__(					self		:Dict     ,   a		:Dict=5_0_2_6_5     ,   a		:Dict=1_0_2_4     ,   a		:Union[str, Any]=1_2     ,   a		:Any=4_0_9_6     ,   a		:str=1_6     ,   a		:str=1_2     ,   a		:Optional[Any]=4_0_9_6     ,   a		:int=1_6     ,   a		:Optional[int]=0.0     ,   a		:Optional[int]=0.0     ,   a		:List[Any]=True     ,   a		:Union[str, Any]=True     ,   a		:int="gelu"     ,   a		:Dict=1_0_2_4     ,   a		:List[Any]=0.1     ,   a		:List[str]=0.0     ,   a		:List[Any]=0.0     ,   a		:str=0.02     ,   a		:int=0     ,   a		:Any=False     ,   a		:Dict=0     ,   a		:int=1     ,   a		:Optional[Any]=1     ,   **a		:Optional[int]     ,   )		-> str:
								__UpperCamelCase	:   List[Any]			   =					vocab_size
								__UpperCamelCase	:   Union[str, Any]			   =					max_position_embeddings
								__UpperCamelCase	:   str			   =					d_model
								__UpperCamelCase	:   Dict			   =					encoder_ffn_dim
								__UpperCamelCase	:   int			   =					encoder_layers
								__UpperCamelCase	:   int			   =					encoder_attention_heads
								__UpperCamelCase	:   List[Any]			   =					decoder_ffn_dim
								__UpperCamelCase	:   List[Any]			   =					decoder_layers
								__UpperCamelCase	:   List[str]			   =					decoder_attention_heads
								__UpperCamelCase	:   str			   =					dropout
								__UpperCamelCase	:   Union[str, Any]			   =					attention_dropout
								__UpperCamelCase	:   List[str]			   =					activation_dropout
								__UpperCamelCase	:   Optional[Any]			   =					activation_function
								__UpperCamelCase	:   Tuple			   =					init_std
								__UpperCamelCase	:   Optional[int]			   =					encoder_layerdrop
								__UpperCamelCase	:   Union[str, Any]			   =					decoder_layerdrop
								__UpperCamelCase	:   Optional[Any]			   =					use_cache
								__UpperCamelCase	:   Union[str, Any]			   =					encoder_layers
								__UpperCamelCase	:   int			   =					scale_embedding  # scale factor will be sqrt(d_model) if True
								super().__init__(
								    pad_token_id=a     ,   eos_token_id=a     ,   is_encoder_decoder=a     ,   decoder_start_token_id=a     ,   forced_eos_token_id=a     ,   **a     ,   )







	@property
	def    _lowerCamelCase				(					self		:Dict						)		-> int:
								return self.encoder_attention_heads







	@property
	def    _lowerCamelCase				(					self		:Optional[Any]						)		-> int:
								return self.d_model