

from __future__ import annotations

import unittest

from transformers import LEDConfig, is_tf_available
from transformers.testing_utils import require_tf, slow

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
			import tensorflow as tf

			from transformers import TFLEDForConditionalGeneration, TFLEDModel

@require_tf
class 							UpperCAmelCase_						:
							"""simple docstring"""







							UpperCAmelCase__			:		Optional[int]             =       LEDConfig
							UpperCAmelCase__			:		Union[str, Any]             =       {}
							UpperCAmelCase__			:		Dict             =       "gelu"


							def __init__(     self			,				_a			,				_a=1_3			,				_a=7			,				_a=True			,				_a=False			,				_a=9_9			,				_a=3_2			,				_a=2			,				_a=4			,				_a=3_7			,				_a=0.1			,				_a=0.1			,				_a=2_0			,				_a=2			,				_a=1			,				_a=0			,				_a=4			,				)       ->       Dict:
												_a      :       Optional[Any]   =						parent
												_a      :       str   =						batch_size
												_a      :       Dict   =						seq_length
												_a      :       Any   =						is_training
												_a      :       Any   =						use_labels
												_a      :       List[Any]   =						vocab_size
												_a      :       Tuple   =						hidden_size
												_a      :       Dict   =						num_hidden_layers
												_a      :       str   =						num_attention_heads
												_a      :       List[Any]   =						intermediate_size

												_a      :       Any   =						hidden_dropout_prob
												_a      :       Any   =						attention_probs_dropout_prob
												_a      :       Tuple   =						max_position_embeddings
												_a      :       List[str]   =						eos_token_id
												_a      :       Any   =						pad_token_id
												_a      :       int   =						bos_token_id
												_a      :       Any   =						attention_window

												# `ModelTesterMixin.test_attention_outputs` is expecting attention tensors to be of size
												# [num_attention_heads, encoder_seq_length, encoder_key_length], but TFLongformerSelfAttention
												# returns attention of shape [num_attention_heads, encoder_seq_length, self.attention_window + 1]
												# because its local attention only attends to `self.attention_window` and one before and one after
												_a      :       Dict   =						self.attention_window + 2

												# because of padding `encoder_seq_length`, is different from `seq_length`. Relevant for
												# the `test_attention_outputs` and `test_hidden_states_output` tests
												_a      :       Tuple   =						(
												    self.seq_length + (self.attention_window - self.seq_length % self.attention_window) % self.attention_window
												)


							def 							__lowercase							(     self			)       ->       Optional[Any]:
												_a      :       Union[str, Any]   =						ids_tensor([self.batch_size, self.seq_length - 1]			,				self.vocab_size			)
												_a      :       Optional[int]   =						tf.expand_dims(tf.constant([self.eos_token_id] * self.batch_size			)			,				1			)
												_a      :       Optional[Any]   =						tf.concat([input_ids, eos_tensor]			,				axis=1			)

												_a      :       Optional[Any]   =						ids_tensor([self.batch_size, self.seq_length]			,				self.vocab_size			)

												_a      :       Dict   =						self.config_cls(
												    vocab_size=self.vocab_size			,				d_model=self.hidden_size			,				encoder_layers=self.num_hidden_layers			,				decoder_layers=self.num_hidden_layers			,				encoder_attention_heads=self.num_attention_heads			,				decoder_attention_heads=self.num_attention_heads			,				encoder_ffn_dim=self.intermediate_size			,				decoder_ffn_dim=self.intermediate_size			,				dropout=self.hidden_dropout_prob			,				attention_dropout=self.attention_probs_dropout_prob			,				max_position_embeddings=self.max_position_embeddings			,				eos_token_ids=[2]			,				bos_token_id=self.bos_token_id			,				pad_token_id=self.pad_token_id			,				decoder_start_token_id=self.pad_token_id			,				attention_window=self.attention_window			,				**self.config_updates			,				)
												_a      :       Optional[int]   =						prepare_led_inputs_dict(_a			,				_a			,				_a			)
												_a      :       int   =						tf.concat(
												    [tf.zeros_like(_a			)[:, :-1], tf.ones_like(_a			)[:, -1:]]			,				axis=-1			,				)
												_a      :       str   =						global_attention_mask
												return config, inputs_dict




							def 							__lowercase							(     self			,				_a			,				_a			)       ->       Any:
												_a      :       Dict   =						TFLEDModel(config=_a			).get_decoder()
												_a      :       Any   =						inputs_dict['''input_ids''']

												_a      :       str   =						input_ids[:1, :]
												_a      :       Optional[int]   =						inputs_dict['''attention_mask'''][:1, :]
												_a      :       Optional[Any]   =						1

												# first forward pass
												_a      :       int   =						model(_a			,				attention_mask=_a			,				use_cache=_a			)

												_a ,   _a      :       Dict   =						outputs.to_tuple()

												# create hypothetical next token and extent to next_input_ids
												_a      :       Tuple   =						ids_tensor((self.batch_size, 3)			,				config.vocab_size			)
												_a      :       int   =						tf.cast(ids_tensor((self.batch_size, 3)			,				2			)			,				tf.inta			)

												# append to next input_ids and
												_a      :       List[str]   =						tf.concat([input_ids, next_tokens]			,				axis=-1			)
												_a      :       Any   =						tf.concat([attention_mask, next_attn_mask]			,				axis=-1			)

												_a      :       int   =						model(_a			,				attention_mask=_a			)[0]
												_a      :       Optional[Any]   =						model(_a			,				attention_mask=_a			,				past_key_values=_a			)[0]

												self.parent.assertEqual(next_tokens.shape[1]			,				output_from_past.shape[1]			)

												# select random slice
												_a      :       str   =						int(ids_tensor((1,)			,				output_from_past.shape[-1]			)			)
												_a      :       List[str]   =						output_from_no_past[:, -3:, random_slice_idx]
												_a      :       Tuple   =						output_from_past[:, :, random_slice_idx]

												# test that outputs are equal for slice
												tf.debugging.assert_near(_a			,				_a			,				rtol=1e-3			)



def   __UpperCAmelCase					(      __a :     int						,__a :     str						,__a :     Optional[Any]						,__a :     Optional[int]=None						,__a :     Optional[int]=None						,__a :     Dict=None						,__a :     List[Any]=None						,)     ->	str:

					"""simple docstring"""

					if attention_mask is None:
										_a      :       Optional[int]   =						tf.cast(tf.math.not_equal(__a						,config.pad_token_id      )						,tf.inta      )
					if decoder_attention_mask is None:
										_a      :       List[Any]   =						tf.concat(
										    [
										        tf.ones(decoder_input_ids[:, :1].shape						,dtype=tf.inta      ),
										        tf.cast(tf.math.not_equal(decoder_input_ids[:, 1:]						,config.pad_token_id      )						,tf.inta      ),
										    ]						,axis=-1						,)
					if head_mask is None:
										_a      :       List[Any]   =						tf.ones((config.encoder_layers, config.encoder_attention_heads)      )
					if decoder_head_mask is None:
										_a      :       Optional[Any]   =						tf.ones((config.decoder_layers, config.decoder_attention_heads)      )
					return {
					    "input_ids": input_ids,
					    "attention_mask": attention_mask,
					    "decoder_input_ids": decoder_input_ids,
					    "decoder_attention_mask": decoder_attention_mask,
					    "head_mask": head_mask,
					    "decoder_head_mask": decoder_head_mask,
					}

@require_tf
class 							UpperCAmelCase_						(     __lowercase							,			__lowercase							,			unittest.TestCase  ):
							"""simple docstring"""







							UpperCAmelCase__			:		Union[str, Any]             =       (TFLEDForConditionalGeneration, TFLEDModel) if is_tf_available() else ()
							UpperCAmelCase__			:		Optional[int]             =       (TFLEDForConditionalGeneration,) if is_tf_available() else ()
							UpperCAmelCase__			:		List[Any]             =       (
							    {
							        "conversational": TFLEDForConditionalGeneration,
							        "feature-extraction": TFLEDModel,
							        "summarization": TFLEDForConditionalGeneration,
							        "text2text-generation": TFLEDForConditionalGeneration,
							        "translation": TFLEDForConditionalGeneration,
							    }
							    if is_tf_available()
							    else {}
							)
							UpperCAmelCase__			:		str             =       True
							UpperCAmelCase__			:		Dict             =       False
							UpperCAmelCase__			:		Optional[Any]             =       False
							UpperCAmelCase__			:		Dict             =       False


							def 							__lowercase							(     self			)       ->       Optional[Any]:
												_a      :       Dict   =						TFLEDModelTester(self			)
												_a      :       Any   =						ConfigTester(self			,				config_class=_a			)


							def 							__lowercase							(     self			)       ->       Union[str, Any]:
												self.config_tester.run_common_tests()


							def 							__lowercase							(     self			)       ->       int:
												_a      :       Optional[Any]   =						self.model_tester.prepare_config_and_inputs_for_common()
												self.model_tester.check_decoder_model_past_large_inputs(*_a			)


							def 							__lowercase							(     self			)       ->       str:
												_a ,   _a      :       List[Any]   =						self.model_tester.prepare_config_and_inputs_for_common()
												_a      :       int   =						tf.zeros_like(inputs_dict['''attention_mask''']			)
												_a      :       Tuple   =						2
												_a      :       Optional[Any]   =						tf.where(
												    tf.range(self.model_tester.seq_length			)[None, :] < num_global_attn_indices			,				1			,				inputs_dict['''global_attention_mask''']			,				)

												_a      :       Tuple   =						True
												_a      :       Union[str, Any]   =						self.model_tester.seq_length
												_a      :       Dict   =						self.model_tester.encoder_seq_length

												def check_decoder_attentions_output(_a			):
																	_a      :       List[str]   =						outputs.decoder_attentions
																	self.assertEqual(len(_a			)			,				self.model_tester.num_hidden_layers			)
																	self.assertListEqual(
																	    list(decoder_attentions[0].shape[-3:]			)			,				[self.model_tester.num_attention_heads, seq_length, seq_length]			,				)

												def check_encoder_attentions_output(_a			):
																	_a      :       Optional[int]   =						[t.numpy() for t in outputs.encoder_attentions]
																	_a      :       Optional[Any]   =						[t.numpy() for t in outputs.encoder_global_attentions]
																	self.assertEqual(len(_a			)			,				self.model_tester.num_hidden_layers			)
																	self.assertEqual(len(_a			)			,				self.model_tester.num_hidden_layers			)
																	self.assertListEqual(
																	    list(attentions[0].shape[-3:]			)			,				[self.model_tester.num_attention_heads, seq_length, seq_length]			,				)
																	self.assertListEqual(
																	    list(global_attentions[0].shape[-3:]			)			,				[self.model_tester.num_attention_heads, encoder_seq_length, num_global_attn_indices]			,				)

												for model_class in self.all_model_classes:
																	_a      :       List[Any]   =						True
																	_a      :       str   =						False
																	_a      :       Any   =						False
																	_a      :       List[Any]   =						model_class(_a			)
																	_a      :       Union[str, Any]   =						model(self._prepare_for_class(_a			,				_a			)			)
																	_a      :       Any   =						len(_a			)
																	self.assertEqual(config.output_hidden_states			,				_a			)
																	check_encoder_attentions_output(_a			)

																	if self.is_encoder_decoder:
																						_a      :       str   =						model_class(_a			)
																						_a      :       Dict   =						model(self._prepare_for_class(_a			,				_a			)			)
																						self.assertEqual(config.output_hidden_states			,				_a			)
																						check_decoder_attentions_output(_a			)

																	# Check that output attentions can also be changed via the config
																	del inputs_dict["output_attentions"]
																	_a      :       Union[str, Any]   =						True
																	_a      :       Tuple   =						model_class(_a			)
																	_a      :       Optional[Any]   =						model(self._prepare_for_class(_a			,				_a			)			)
																	self.assertEqual(config.output_hidden_states			,				_a			)
																	check_encoder_attentions_output(_a			)

																	# Check attention is always last and order is fine
																	_a      :       Tuple   =						True
																	_a      :       Dict   =						True
																	_a      :       Union[str, Any]   =						model_class(_a			)
																	_a      :       Optional[Any]   =						model(self._prepare_for_class(_a			,				_a			)			)

																	self.assertEqual(out_len + (2 if self.is_encoder_decoder else 1)			,				len(_a			)			)
																	self.assertEqual(model.config.output_hidden_states			,				_a			)
																	check_encoder_attentions_output(_a			)


							@unittest.skip('''LED keeps using potentially symbolic tensors in conditionals and breaks tracing.'''			)
							def 							__lowercase							(     self			)       ->       Union[str, Any]:
												pass




							def 							__lowercase							(     self			)       ->       List[str]:
												# TODO: Head-masking not yet implement
												pass



def   __UpperCAmelCase					(      __a :     Tuple      )     ->	Any:

					"""simple docstring"""

					return tf.constant(__a						,dtype=tf.intaa      )


a__												=						1E-4







@slow
@require_tf
class 							UpperCAmelCase_						(     unittest.TestCase  ):
							"""simple docstring"""







							def 							__lowercase							(     self			)       ->       List[Any]:
												_a      :       Dict   =						TFLEDForConditionalGeneration.from_pretrained('''allenai/led-base-16384'''			).led

												# change to intended input here
												_a      :       str   =						_long_tensor([5_1_2 * [0, 3_1_4_1_4, 2_3_2, 3_2_8, 7_4_0, 1_1_4_0, 1_2_6_9_5, 6_9]]			)
												_a      :       Tuple   =						_long_tensor([1_2_8 * [0, 3_1_4_1_4, 2_3_2, 3_2_8, 7_4_0, 1_1_4_0, 1_2_6_9_5, 6_9]]			)
												_a      :       Any   =						prepare_led_inputs_dict(model.config			,				_a			,				_a			)
												_a      :       Optional[int]   =						model(**_a			)[0]
												_a      :       str   =						(1, 1_0_2_4, 7_6_8)
												self.assertEqual(output.shape			,				_a			)
												# change to expected output here
												_a      :       str   =						tf.convert_to_tensor(
												    [[2.3050, 2.8279, 0.6531], [-1.8457, -0.1455, -3.5661], [-1.0186, 0.4586, -2.2043]]			,				)
												tf.debugging.assert_near(output[:, :3, :3]			,				_a			,				atol=1e-3			)




							def 							__lowercase							(     self			)       ->       str:
												_a      :       Any   =						TFLEDForConditionalGeneration.from_pretrained('''allenai/led-base-16384'''			)

												# change to intended input here
												_a      :       List[str]   =						_long_tensor([5_1_2 * [0, 3_1_4_1_4, 2_3_2, 3_2_8, 7_4_0, 1_1_4_0, 1_2_6_9_5, 6_9]]			)
												_a      :       Dict   =						_long_tensor([1_2_8 * [0, 3_1_4_1_4, 2_3_2, 3_2_8, 7_4_0, 1_1_4_0, 1_2_6_9_5, 6_9]]			)
												_a      :       Union[str, Any]   =						prepare_led_inputs_dict(model.config			,				_a			,				_a			)
												_a      :       Union[str, Any]   =						model(**_a			)[0]
												_a      :       Optional[int]   =						(1, 1_0_2_4, model.config.vocab_size)
												self.assertEqual(output.shape			,				_a			)
												# change to expected output here
												_a      :       List[str]   =						tf.convert_to_tensor(
												    [[33.6507, 6.4572, 16.8089], [5.8739, -2.4238, 11.2902], [-3.2139, -4.3149, 4.2783]]			,				)
												tf.debugging.assert_near(output[:, :3, :3]			,				_a			,				atol=1e-3			,				rtol=1e-3			)






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

import transformers
from transformers import (
    CONFIG_MAPPING,
    IMAGE_PROCESSOR_MAPPING,
    AutoConfig,
    AutoImageProcessor,
    CLIPConfig,
    CLIPImageProcessor,
)
from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER


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

from test_module.custom_configuration import CustomConfig  # noqa E402
from test_module.custom_image_processing import CustomImageProcessor  # noqa E402

class 							UpperCAmelCase_						(     unittest.TestCase  ):
							"""simple docstring"""







							def 							__lowercase							(     self			)       ->       List[Any]:
												_a      :       int   =						0


							def 							__lowercase							(     self			)       ->       List[str]:
												_a      :       Dict   =						AutoImageProcessor.from_pretrained('''openai/clip-vit-base-patch32'''			)
												self.assertIsInstance(_a			,				_a			)


							def 							__lowercase							(     self			)       ->       Union[str, Any]:
												with tempfile.TemporaryDirectory() as tmpdirname:
																	_a      :       Tuple   =						Path(_a			) / '''preprocessor_config.json'''
																	_a      :       Optional[Any]   =						Path(_a			) / '''config.json'''
																	json.dump(
																	    {'''image_processor_type''': '''CLIPImageProcessor''', '''processor_class''': '''CLIPProcessor'''}			,				open(_a			,				'''w'''			)			,				)
																	json.dump({'''model_type''': '''clip'''}			,				open(_a			,				'''w'''			)			)

																	_a      :       List[str]   =						AutoImageProcessor.from_pretrained(_a			)
																	self.assertIsInstance(_a			,				_a			)


							def 							__lowercase							(     self			)       ->       Optional[Any]:
												# Ensure we can load the image processor from the feature extractor config
												with tempfile.TemporaryDirectory() as tmpdirname:
																	_a      :       Optional[int]   =						Path(_a			) / '''preprocessor_config.json'''
																	_a      :       Any   =						Path(_a			) / '''config.json'''
																	json.dump(
																	    {'''feature_extractor_type''': '''CLIPFeatureExtractor''', '''processor_class''': '''CLIPProcessor'''}			,				open(_a			,				'''w'''			)			,				)
																	json.dump({'''model_type''': '''clip'''}			,				open(_a			,				'''w'''			)			)

																	_a      :       Optional[Any]   =						AutoImageProcessor.from_pretrained(_a			)
																	self.assertIsInstance(_a			,				_a			)


							def 							__lowercase							(     self			)       ->       Optional[Any]:
												with tempfile.TemporaryDirectory() as tmpdirname:
																	_a      :       Dict   =						CLIPConfig()

																	# Create a dummy config file with image_proceesor_type
																	_a      :       Tuple   =						Path(_a			) / '''preprocessor_config.json'''
																	_a      :       List[str]   =						Path(_a			) / '''config.json'''
																	json.dump(
																	    {'''image_processor_type''': '''CLIPImageProcessor''', '''processor_class''': '''CLIPProcessor'''}			,				open(_a			,				'''w'''			)			,				)
																	json.dump({'''model_type''': '''clip'''}			,				open(_a			,				'''w'''			)			)

																	# remove image_processor_type to make sure config.json alone is enough to load image processor locally
																	_a      :       Tuple   =						AutoImageProcessor.from_pretrained(_a			).to_dict()

																	config_dict.pop('''image_processor_type'''			)
																	_a      :       Tuple   =						CLIPImageProcessor(**_a			)

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

																	_a      :       List[str]   =						AutoImageProcessor.from_pretrained(_a			)

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

												self.assertIsInstance(_a			,				_a			)


							def 							__lowercase							(     self			)       ->       Dict:
												with tempfile.TemporaryDirectory() as tmpdirname:
																	_a      :       Optional[int]   =						Path(_a			) / '''preprocessor_config.json'''
																	json.dump(
																	    {'''image_processor_type''': '''CLIPImageProcessor''', '''processor_class''': '''CLIPProcessor'''}			,				open(_a			,				'''w'''			)			,				)

																	_a      :       List[str]   =						AutoImageProcessor.from_pretrained(_a			)
																	self.assertIsInstance(_a			,				_a			)


							def 							__lowercase							(     self			)       ->       Any:
												with self.assertRaisesRegex(
												    _a			,				'''clip-base is not a local folder and is not a valid model identifier'''			):
																	_a      :       Dict   =						AutoImageProcessor.from_pretrained('''clip-base'''			)


							def 							__lowercase							(     self			)       ->       List[Any]:
												with self.assertRaisesRegex(
												    _a			,				R'''aaaaaa is not a valid git identifier \(branch name, tag name or commit id\)'''			):
																	_a      :       List[str]   =						AutoImageProcessor.from_pretrained(_a			,				revision='''aaaaaa'''			)


							def 							__lowercase							(     self			)       ->       Dict:
												with self.assertRaisesRegex(
												    _a			,				'''hf-internal-testing/config-no-model does not appear to have a file named preprocessor_config.json.'''			,				):
																	_a      :       Optional[int]   =						AutoImageProcessor.from_pretrained('''hf-internal-testing/config-no-model'''			)


							def 							__lowercase							(     self			)       ->       Union[str, Any]:
												# If remote code is not set, we will time out when asking whether to load the model.
												with self.assertRaises(_a			):
																	_a      :       str   =						AutoImageProcessor.from_pretrained('''hf-internal-testing/test_dynamic_image_processor'''			)
												# If remote code is disabled, we can't load this config.
												with self.assertRaises(_a			):
																	_a      :       Optional[Any]   =						AutoImageProcessor.from_pretrained(
																	    '''hf-internal-testing/test_dynamic_image_processor'''			,				trust_remote_code=_a			)

												_a      :       Union[str, Any]   =						AutoImageProcessor.from_pretrained(
												    '''hf-internal-testing/test_dynamic_image_processor'''			,				trust_remote_code=_a			)
												self.assertEqual(image_processor.__class__.__name__			,				'''NewImageProcessor'''			)

												# Test image processor can be reloaded.
												with tempfile.TemporaryDirectory() as tmp_dir:
																	image_processor.save_pretrained(_a			)
																	_a      :       Optional[Any]   =						AutoImageProcessor.from_pretrained(_a			,				trust_remote_code=_a			)
												self.assertEqual(reloaded_image_processor.__class__.__name__			,				'''NewImageProcessor'''			)


							def 							__lowercase							(     self			)       ->       Dict:
												try:
																	AutoConfig.register('''custom'''			,				_a			)
																	AutoImageProcessor.register(_a			,				_a			)
																	# Trying to register something existing in the Transformers library will raise an error
																	with self.assertRaises(_a			):
																						AutoImageProcessor.register(_a			,				_a			)

																	with tempfile.TemporaryDirectory() as tmpdirname:
																						_a      :       int   =						Path(_a			) / '''preprocessor_config.json'''
																						_a      :       int   =						Path(_a			) / '''config.json'''
																						json.dump(
																						    {'''feature_extractor_type''': '''CLIPFeatureExtractor''', '''processor_class''': '''CLIPProcessor'''}			,				open(_a			,				'''w'''			)			,				)
																						json.dump({'''model_type''': '''clip'''}			,				open(_a			,				'''w'''			)			)

																						_a      :       int   =						CustomImageProcessor.from_pretrained(_a			)

																	# Now that the config is registered, it can be used as any other config with the auto-API
																	with tempfile.TemporaryDirectory() as tmp_dir:
																						image_processor.save_pretrained(_a			)
																						_a      :       Optional[Any]   =						AutoImageProcessor.from_pretrained(_a			)
																						self.assertIsInstance(_a			,				_a			)

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




							def 							__lowercase							(     self			)       ->       Union[str, Any]:

												class 							UpperCAmelCase_						(     __lowercase  ):
																			"""simple docstring"""







																			UpperCAmelCase__			:		Tuple             =       True

												try:
																	AutoConfig.register('''custom'''			,				_a			)
																	AutoImageProcessor.register(_a			,				_a			)
																	# If remote code is not set, the default is to use local
																	_a      :       str   =						AutoImageProcessor.from_pretrained('''hf-internal-testing/test_dynamic_image_processor'''			)
																	self.assertEqual(image_processor.__class__.__name__			,				'''NewImageProcessor'''			)
																	self.assertTrue(image_processor.is_local			)

																	# If remote code is disabled, we load the local one.
																	_a      :       int   =						AutoImageProcessor.from_pretrained(
																	    '''hf-internal-testing/test_dynamic_image_processor'''			,				trust_remote_code=_a			)
																	self.assertEqual(image_processor.__class__.__name__			,				'''NewImageProcessor'''			)
																	self.assertTrue(image_processor.is_local			)

																	# If remote is enabled, we load from the Hub
																	_a      :       Dict   =						AutoImageProcessor.from_pretrained(
																	    '''hf-internal-testing/test_dynamic_image_processor'''			,				trust_remote_code=_a			)
																	self.assertEqual(image_processor.__class__.__name__			,				'''NewImageProcessor'''			)
																	self.assertTrue(not hasattr(_a			,				'''is_local'''			)			)

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



