



'''simple docstring'''


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

import transformers
from transformers import (
    CONFIG_MAPPING,
    FEATURE_EXTRACTOR_MAPPING,
    AutoConfig,
    AutoFeatureExtractor,
    WavaVecaConfig,
    WavaVecaFeatureExtractor,
)
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
from test_module.custom_feature_extraction import CustomFeatureExtractor  # noqa E402


lowerCAmelCase__						:       Optional[int]										=						get_tests_dir("""fixtures""")
lowerCAmelCase__						:       List[str]										=						get_tests_dir("""fixtures/dummy_feature_extractor_config.json""")
lowerCAmelCase__						:       Union[str, Any]										=						get_tests_dir("""fixtures/dummy-config.json""")




class     a			(				unittest.TestCase       ):






						"""simple docstring"""




						def       __magic_name__							(							self					:      Dict  ):



								'''simple docstring'''



								snake_case__						:       Dict       						=  0







						def       __magic_name__							(							self					:      int  ):



								'''simple docstring'''



								snake_case__						:       List[str]       						=  AutoFeatureExtractor.from_pretrained('''facebook/wav2vec2-base-960h'''  )
								self.assertIsInstance(snake_case_			,			snake_case_  )







						def       __magic_name__							(							self					:      List[str]  ):



								'''simple docstring'''



								snake_case__						:       int       						=  AutoFeatureExtractor.from_pretrained(snake_case_  )
								self.assertIsInstance(snake_case_			,			snake_case_  )







						def       __magic_name__							(							self					:      Optional[Any]  ):



								'''simple docstring'''



								with tempfile.TemporaryDirectory() as tmpdirname:
										snake_case__						:       Optional[int]       						=  WavaVecaConfig()

										# remove feature_extractor_type to make sure config.json alone is enough to load feature processor locally
										snake_case__						:       Optional[int]       						=  AutoFeatureExtractor.from_pretrained(snake_case_  ).to_dict()

										config_dict.pop('''feature_extractor_type'''  )
										snake_case__						:       Optional[Any]       						=  WavaVecaFeatureExtractor(**snake_case_  )

										# save in new folder
										model_config.save_pretrained(snake_case_  )
										config.save_pretrained(snake_case_  )

										snake_case__						:       List[str]       						=  AutoFeatureExtractor.from_pretrained(snake_case_  )

										# make sure private variable is not incorrectly saved
										snake_case__						:       Optional[Any]       						=  json.loads(config.to_json_string()  )
										self.assertTrue('''_processor_class''' not in dict_as_saved  )

								self.assertIsInstance(snake_case_			,			snake_case_  )







						def       __magic_name__							(							self					:      Tuple  ):



								'''simple docstring'''



								snake_case__						:       Any       						=  AutoFeatureExtractor.from_pretrained(snake_case_  )
								self.assertIsInstance(snake_case_			,			snake_case_  )







						def       __magic_name__							(							self					:      Optional[int]  ):



								'''simple docstring'''



								with self.assertRaisesRegex(
								    snake_case_			,			'''bert-base is not a local folder and is not a valid model identifier'''  ):
										snake_case__						:       int       						=  AutoFeatureExtractor.from_pretrained('''bert-base'''  )







						def       __magic_name__							(							self					:      Dict  ):



								'''simple docstring'''



								with self.assertRaisesRegex(
								    snake_case_			,			R'''aaaaaa is not a valid git identifier \(branch name, tag name or commit id\)'''  ):
										snake_case__						:       int       						=  AutoFeatureExtractor.from_pretrained(snake_case_			,			revision='''aaaaaa'''  )







						def       __magic_name__							(							self					:      str  ):



								'''simple docstring'''



								with self.assertRaisesRegex(
								    snake_case_			,			'''hf-internal-testing/config-no-model does not appear to have a file named preprocessor_config.json.'''			,			):
										snake_case__						:       Optional[Any]       						=  AutoFeatureExtractor.from_pretrained('''hf-internal-testing/config-no-model'''  )







						def       __magic_name__							(							self					:      List[Any]  ):



								'''simple docstring'''



								with self.assertRaises(snake_case_  ):
										snake_case__						:       Tuple       						=  AutoFeatureExtractor.from_pretrained(
										    '''hf-internal-testing/test_dynamic_feature_extractor'''  )
								# If remote code is disabled, we can't load this config.
								with self.assertRaises(snake_case_  ):
										snake_case__						:       int       						=  AutoFeatureExtractor.from_pretrained(
										    '''hf-internal-testing/test_dynamic_feature_extractor'''			,			trust_remote_code=snake_case_  )

								snake_case__						:       List[str]       						=  AutoFeatureExtractor.from_pretrained(
								    '''hf-internal-testing/test_dynamic_feature_extractor'''			,			trust_remote_code=snake_case_  )
								self.assertEqual(feature_extractor.__class__.__name__			,			'''NewFeatureExtractor'''  )

								# Test feature extractor can be reloaded.
								with tempfile.TemporaryDirectory() as tmp_dir:
										feature_extractor.save_pretrained(snake_case_  )
										snake_case__						:       Any       						=  AutoFeatureExtractor.from_pretrained(snake_case_			,			trust_remote_code=snake_case_  )
								self.assertEqual(reloaded_feature_extractor.__class__.__name__			,			'''NewFeatureExtractor'''  )







						def       __magic_name__							(							self					:      Union[str, Any]  ):



								'''simple docstring'''



								try:
										AutoConfig.register('''custom'''			,			snake_case_  )
										AutoFeatureExtractor.register(snake_case_			,			snake_case_  )
										# Trying to register something existing in the Transformers library will raise an error
										with self.assertRaises(snake_case_  ):
												AutoFeatureExtractor.register(snake_case_			,			snake_case_  )

										# Now that the config is registered, it can be used as any other config with the auto-API
										snake_case__						:       str       						=  CustomFeatureExtractor.from_pretrained(snake_case_  )
										with tempfile.TemporaryDirectory() as tmp_dir:
												feature_extractor.save_pretrained(snake_case_  )
												snake_case__						:       List[str]       						=  AutoFeatureExtractor.from_pretrained(snake_case_  )
												self.assertIsInstance(snake_case_			,			snake_case_  )

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







						def       __magic_name__							(							self					:      Optional[int]  ):



								'''simple docstring'''



								class     a			(				__UpperCAmelCase       ):






														"""simple docstring"""




														__UpperCAmelCase			     =    True

								try:
										AutoConfig.register('''custom'''			,			snake_case_  )
										AutoFeatureExtractor.register(snake_case_			,			snake_case_  )
										# If remote code is not set, the default is to use local
										snake_case__						:       Union[str, Any]       						=  AutoFeatureExtractor.from_pretrained(
										    '''hf-internal-testing/test_dynamic_feature_extractor'''  )
										self.assertEqual(feature_extractor.__class__.__name__			,			'''NewFeatureExtractor'''  )
										self.assertTrue(feature_extractor.is_local  )

										# If remote code is disabled, we load the local one.
										snake_case__						:       List[Any]       						=  AutoFeatureExtractor.from_pretrained(
										    '''hf-internal-testing/test_dynamic_feature_extractor'''			,			trust_remote_code=snake_case_  )
										self.assertEqual(feature_extractor.__class__.__name__			,			'''NewFeatureExtractor'''  )
										self.assertTrue(feature_extractor.is_local  )

										# If remote is enabled, we load from the Hub
										snake_case__						:       Optional[int]       						=  AutoFeatureExtractor.from_pretrained(
										    '''hf-internal-testing/test_dynamic_feature_extractor'''			,			trust_remote_code=snake_case_  )
										self.assertEqual(feature_extractor.__class__.__name__			,			'''NewFeatureExtractor'''  )
										self.assertTrue(not hasattr(snake_case_			,			'''is_local'''  )  )

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






'''simple docstring'''


from collections.abc import Sequence




def 	_a       (				__lowerCAmelCase		:      Sequence[int] | None = None     ):

		"""simple docstring"""

		if nums is None or not nums:
				raise ValueError('''Input sequence should not be empty'''     )

		snake_case__						:       Optional[Any]       						=  nums[0]
		for i in range(1   ,							len(__lowerCAmelCase     )     ):
				snake_case__						:       Tuple       						=  nums[i]
				snake_case__						:       Optional[int]       						=  max(__lowerCAmelCase   ,							ans + num   ,							__lowerCAmelCase     )

		return ans


if __name__ == "__main__":
					import doctest

					doctest.testmod()

					# Try on a sample input from the user
					lowerCAmelCase__						:       str										=						int(input("""Enter number of elements : """).strip())
					lowerCAmelCase__						:       Dict										=						list(map(int, input("""\nEnter the numbers : """).strip().split()))[:n]
					print(max_subsequence_sum(array))



