





"""simple docstring"""




import importlib
import json
import os
import sys
import tempfile
import unittest
from pathlib import Path

import transformers
import transformers.models.auto
from transformers.models.auto.configuration_auto import CONFIG_MAPPING, AutoConfig
from transformers.models.bert.configuration_bert import BertConfig
from transformers.models.roberta.configuration_roberta import RobertaConfig
from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, get_tests_dir


sys.path.append(str(Path(__file__).parent.parent.parent.parent / '''utils'''))

from test_module.custom_configuration import CustomConfig  # noqa E402


a						: str     	=			get_tests_dir('''fixtures/dummy-config.json''')


class        __UpperCamelCase				(						unittest.TestCase						):






							def     __a   (   self      )	-> Any:
								a      :		Tuple	=				0






							def     __a   (   self      )	-> Union[str, Any]:
								self.assertIsNotNone(transformers.models.auto.__spec__      )
								self.assertIsNotNone(importlib.util.find_spec("transformers.models.auto"      )      )






							def     __a   (   self      )	-> Tuple:
								a      :		str	=				AutoConfig.from_pretrained("bert-base-uncased"      )
								self.assertIsInstance(lowerCAmelCase__      ,					lowerCAmelCase__      )






							def     __a   (   self      )	-> int:
								a      :		Dict	=				AutoConfig.from_pretrained(lowerCAmelCase__      )
								self.assertIsInstance(lowerCAmelCase__      ,					lowerCAmelCase__      )






							def     __a   (   self      )	-> Dict:
								a      :		int	=				AutoConfig.from_pretrained(lowerCAmelCase__      )
								self.assertIsInstance(lowerCAmelCase__      ,					lowerCAmelCase__      )






							def     __a   (   self      )	-> Optional[Any]:
								a      :		List[str]	=				AutoConfig.for_model("roberta"      )
								self.assertIsInstance(lowerCAmelCase__      ,					lowerCAmelCase__      )






							def     __a   (   self      )	-> List[Any]:
								with tempfile.TemporaryDirectory() as tmp_dir:
									# This model name contains bert and roberta, but roberta ends up being picked.
									a      :		Any	=				os.path.join(lowerCAmelCase__      ,					"fake-roberta"      )
									os.makedirs(lowerCAmelCase__      ,					exist_ok=lowerCAmelCase__      )
									with open(os.path.join(lowerCAmelCase__      ,					"config.json"      )      ,					"w"      ) as f:
										f.write(json.dumps({}      )      )
									a      :		str	=				AutoConfig.from_pretrained(lowerCAmelCase__      )
									self.assertEqual(type(lowerCAmelCase__      )      ,					lowerCAmelCase__      )






							def     __a   (   self      )	-> Dict:
								try:
									AutoConfig.register("custom"      ,					lowerCAmelCase__      )
									# Wrong model type will raise an error
									with self.assertRaises(lowerCAmelCase__      ):
										AutoConfig.register("model"      ,					lowerCAmelCase__      )
									# Trying to register something existing in the Transformers library will raise an error
									with self.assertRaises(lowerCAmelCase__      ):
										AutoConfig.register("bert"      ,					lowerCAmelCase__      )

									# Now that the config is registered, it can be used as any other config with the auto-API
									a      :		List[Any]	=				CustomConfig()
									with tempfile.TemporaryDirectory() as tmp_dir:
										config.save_pretrained(lowerCAmelCase__      )
										a      :		int	=				AutoConfig.from_pretrained(lowerCAmelCase__      )
										self.assertIsInstance(lowerCAmelCase__      ,					lowerCAmelCase__      )

								finally:
									if "custom" in CONFIG_MAPPING._extra_content:
										del CONFIG_MAPPING._extra_content["custom"]






							def     __a   (   self      )	-> Optional[Any]:
								with self.assertRaisesRegex(
								    lowerCAmelCase__      ,					"bert-base is not a local folder and is not a valid model identifier"      ):
									a      :		str	=				AutoConfig.from_pretrained("bert-base"      )






							def     __a   (   self      )	-> Optional[int]:
								with self.assertRaisesRegex(
								    lowerCAmelCase__      ,					R"aaaaaa is not a valid git identifier \(branch name, tag name or commit id\)"      ):
									a      :		str	=				AutoConfig.from_pretrained(lowerCAmelCase__      ,					revision="aaaaaa"      )






							def     __a   (   self      )	-> Tuple:
								with self.assertRaisesRegex(
								    lowerCAmelCase__      ,					"hf-internal-testing/no-config-test-repo does not appear to have a file named config.json."      ,					):
									a      :		List[Any]	=				AutoConfig.from_pretrained("hf-internal-testing/no-config-test-repo"      )






							def     __a   (   self      )	-> int:
								# If remote code is not set, we will time out when asking whether to load the model.
								with self.assertRaises(lowerCAmelCase__      ):
									a      :		Optional[Any]	=				AutoConfig.from_pretrained("hf-internal-testing/test_dynamic_model"      )
								# If remote code is disabled, we can't load this config.
								with self.assertRaises(lowerCAmelCase__      ):
									a      :		Optional[int]	=				AutoConfig.from_pretrained("hf-internal-testing/test_dynamic_model"      ,					trust_remote_code=lowerCAmelCase__      )

								a      :		Optional[int]	=				AutoConfig.from_pretrained("hf-internal-testing/test_dynamic_model"      ,					trust_remote_code=lowerCAmelCase__      )
								self.assertEqual(config.__class__.__name__      ,					"NewModelConfig"      )

								# Test config can be reloaded.
								with tempfile.TemporaryDirectory() as tmp_dir:
									config.save_pretrained(lowerCAmelCase__      )
									a      :		int	=				AutoConfig.from_pretrained(lowerCAmelCase__      ,					trust_remote_code=lowerCAmelCase__      )
								self.assertEqual(reloaded_config.__class__.__name__      ,					"NewModelConfig"      )






							def     __a   (   self      )	-> Tuple:


								class        __UpperCamelCase				(						a__						):
															lowerCamelCase   :					List[str]      					="""new-model"""

								try:
									AutoConfig.register("new-model"      ,					lowerCAmelCase__      )
									# If remote code is not set, the default is to use local
									a      :		Any	=				AutoConfig.from_pretrained("hf-internal-testing/test_dynamic_model"      )
									self.assertEqual(config.__class__.__name__      ,					"NewModelConfigLocal"      )

									# If remote code is disabled, we load the local one.
									a      :		str	=				AutoConfig.from_pretrained("hf-internal-testing/test_dynamic_model"      ,					trust_remote_code=lowerCAmelCase__      )
									self.assertEqual(config.__class__.__name__      ,					"NewModelConfigLocal"      )

									# If remote is enabled, we load from the Hub
									a      :		Tuple	=				AutoConfig.from_pretrained("hf-internal-testing/test_dynamic_model"      ,					trust_remote_code=lowerCAmelCase__      )
									self.assertEqual(config.__class__.__name__      ,					"NewModelConfig"      )

								finally:
									if "new-model" in CONFIG_MAPPING._extra_content:
										del CONFIG_MAPPING._extra_content["new-model"]









"""simple docstring"""




from datetime import datetime

import requests






def       _SCREAMING_SNAKE_CASE		(	_lowercase						:    str					) ->bytes:






	'''simple docstring'''






	a      :		Dict	=				"https://downloadgram.net/wp-json/wppress/video-downloader/video?url="
	a      :		Dict	=				requests.get(base_url + url					).json()[0]["urls"][0]["src"]
	return requests.get(_lowercase					).content


if __name__ == "__main__":
		a						: str     	=			input('''Enter Video/IGTV url: ''').strip()
		a						: Any     	=			F'''{datetime.now():%Y-%m-%d_%H:%M:%S}.mp4'''
		with open(file_name, '''wb''') as fp:
				fp.write(download_video(url))
		print(F'''Done. Video saved to disk as {file_name}.''')


