



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


UpperCAmelCase							       =    logging.get_logger(__name__)

UpperCAmelCase							       =    {
    """google/pegasus-x-base""": """https://huggingface.co/google/pegasus-x-base/resolve/main/config.json""",
    """google/pegasus-x-large""": """https://huggingface.co/google/pegasus-x-large/resolve/main/config.json""",
    # See all PEGASUS-X models at https://huggingface.co/models?filter=pegasus-x
}

class        __snake_case					(      A_):







							'''simple docstring'''






							UpperCamelCase__ :					List[Any]			   =    "pegasus_x"
							UpperCamelCase__ :					str			   =    ["past_key_values"]
							UpperCamelCase__ :					Optional[int]			   =    {"num_attention_heads": "encoder_attention_heads", "hidden_size": "d_model"}


							def __init__(							self     ,     a_=96_103     ,     a_=16_384     ,     a_=16     ,     a_=4_096     ,     a_=16     ,     a_=16     ,     a_=4_096     ,     a_=16     ,     a_=0.0     ,     a_=0.0     ,     a_=True     ,     a_=True     ,     a_="gelu"     ,     a_=1_024     ,     a_=0.1     ,     a_=0.0     ,     a_=0.0     ,     a_=0.02     ,     a_=0     ,     a_=True     ,     a_=0     ,     a_=1     ,     a_=1     ,     a_=32     ,     a_=512     ,     a_=True     ,     **a_     ,     ):
											a__ 					=						vocab_size
											a__ 					=						max_position_embeddings
											a__ 					=						d_model
											a__ 					=						encoder_ffn_dim
											a__ 					=						encoder_layers
											a__ 					=						encoder_attention_heads
											a__ 					=						decoder_ffn_dim
											a__ 					=						decoder_layers
											a__ 					=						decoder_attention_heads
											a__ 					=						dropout
											a__ 					=						attention_dropout
											a__ 					=						activation_dropout
											a__ 					=						activation_function
											a__ 					=						init_std
											a__ 					=						encoder_layerdrop
											a__ 					=						decoder_layerdrop
											a__ 					=						use_cache
											a__ 					=						encoder_layers
											a__ 					=						scale_embedding  # scale factor will be sqrt(d_model) if True

											a__ 					=						num_global_tokens
											a__ 					=						block_size
											a__ 					=						stagger_local_blocks

											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 _a					(							self						):
											return self.encoder_attention_heads







							@property
							def _a					(							self						):
											return self.d_model



import os
import shutil
import unittest
from unittest.mock import patch

from transformers.testing_utils import CaptureStd, is_pt_tf_cross_test, require_torch







class      lowerCamelCase		(  unittest.TestCase  ):





     @patch("sys.argv"				,    ["fakeprogrampath", "env"]   )
     def 		UpperCAmelCase(self      :    Optional[Any]   )						->						Dict:
         # test transformers-cli env
         import transformers.commands.transformers_cli

         with CaptureStd() as cs:
             transformers.commands.transformers_cli.main()
         self.assertIn("Python version"				,    cs.out   )
         self.assertIn("Platform"				,    cs.out   )
         self.assertIn("Using distributed or parallel set-up in script?"				,    cs.out   )





     @is_pt_tf_cross_test
     @patch(
         "sys.argv"				,    ["fakeprogrampath", "pt-to-tf", "--model-name", "hf-internal-testing/tiny-random-gptj", "--no-pr"]   )
     def 		UpperCAmelCase(self      :    Any   )						->						int:
         import transformers.commands.transformers_cli

         shutil.rmtree("/tmp/hf-internal-testing/tiny-random-gptj"				,    ignore_errors=_A   )  # cleans potential past runs
         transformers.commands.transformers_cli.main()

         # The original repo has no TF weights -- if they exist, they were created by the CLI
         self.assertTrue(os.path.exists("/tmp/hf-internal-testing/tiny-random-gptj/tf_model.h5"   )   )





     @require_torch
     @patch("sys.argv"				,    ["fakeprogrampath", "download", "hf-internal-testing/tiny-random-gptj", "--cache-dir", "/tmp"]   )
     def 		UpperCAmelCase(self      :    Dict   )						->						List[Any]:
         import transformers.commands.transformers_cli

         # # remove any previously downloaded model to start clean
         shutil.rmtree("/tmp/models--hf-internal-testing--tiny-random-gptj"				,    ignore_errors=_A   )

         # run the command
         transformers.commands.transformers_cli.main()

         # check if the model files are downloaded correctly on /tmp/models--hf-internal-testing--tiny-random-gptj
         self.assertTrue(os.path.exists("/tmp/models--hf-internal-testing--tiny-random-gptj/blobs"   )   )
         self.assertTrue(os.path.exists("/tmp/models--hf-internal-testing--tiny-random-gptj/refs"   )   )
         self.assertTrue(os.path.exists("/tmp/models--hf-internal-testing--tiny-random-gptj/snapshots"   )   )





     @require_torch
     @patch(
         "sys.argv"				,    [
             "fakeprogrampath",
             "download",
             "hf-internal-testing/test_dynamic_model_with_tokenizer",
             "--trust-remote-code",
             "--cache-dir",
             "/tmp",
         ]				,    )
     def 		UpperCAmelCase(self      :    Any   )						->						List[str]:
         import transformers.commands.transformers_cli

         # # remove any previously downloaded model to start clean
         shutil.rmtree("/tmp/models--hf-internal-testing--test_dynamic_model_with_tokenizer"				,    ignore_errors=_A   )

         # run the command
         transformers.commands.transformers_cli.main()

         # check if the model files are downloaded correctly on /tmp/models--hf-internal-testing--test_dynamic_model_with_tokenizer
         self.assertTrue(os.path.exists("/tmp/models--hf-internal-testing--test_dynamic_model_with_tokenizer/blobs"   )   )
         self.assertTrue(os.path.exists("/tmp/models--hf-internal-testing--test_dynamic_model_with_tokenizer/refs"   )   )
         self.assertTrue(
             os.path.exists("/tmp/models--hf-internal-testing--test_dynamic_model_with_tokenizer/snapshots"   )   )

