




import inspect
import unittest

import numpy as np

from tests.test_modeling_common import floats_tensor
from transformers import MaskaFormerConfig, is_torch_available, is_vision_available
from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device
from transformers.utils import cached_property

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
						import torch

						from transformers import MaskaFormerForUniversalSegmentation, MaskaFormerModel

						if is_vision_available():
												from transformers import MaskaFormerImageProcessor

if is_vision_available():
						from PIL import Image




class       lowerCAmelCase__       :


				"""simple docstring"""





				def __init__(     self					:	Union[str, Any]    ,   lowercase__					:	Dict    ,   lowercase__					:	Union[str, Any]=2    ,   lowercase__					:	Dict=True    ,   lowercase__					:	Tuple=False    ,   lowercase__					:	Tuple=1_0    ,   lowercase__					:	str=3    ,   lowercase__					:	Union[str, Any]=3_2 * 8    ,   lowercase__					:	int=3_2 * 8    ,   lowercase__					:	Union[str, Any]=4    ,   lowercase__					:	Optional[Any]=6_4    ,   ):
						__lowercase				:		int												=				parent
						__lowercase				:		List[str]												=				batch_size
						__lowercase				:		Any												=				is_training
						__lowercase				:		int												=				use_auxiliary_loss
						__lowercase				:		List[Any]												=				num_queries
						__lowercase				:		Any												=				num_channels
						__lowercase				:		str												=				min_size
						__lowercase				:		Dict												=				max_size
						__lowercase				:		Optional[int]												=				num_labels
						__lowercase				:		str												=				hidden_dim
						__lowercase				:		Optional[int]												=				hidden_dim



				def       snake_case    (     self					:	Optional[Any]						):
						__lowercase				:		List[str]												=				floats_tensor([self.batch_size, self.num_channels, self.min_size, self.max_size]						).to(
						    lowerCamelCase_						)

						__lowercase				:		Tuple												=				torch.ones([self.batch_size, self.min_size, self.max_size]    ,   device=lowerCamelCase_						)

						__lowercase				:		Optional[int]												=				(
						    torch.rand([self.batch_size, self.num_labels, self.min_size, self.max_size]    ,   device=lowerCamelCase_						) > 0.5
						).float()
						__lowercase				:		List[Any]												=				(torch.rand((self.batch_size, self.num_labels)    ,   device=lowerCamelCase_						) > 0.5).long()

						__lowercase				:		Tuple												=				self.get_config()
						return config, pixel_values, pixel_mask, mask_labels, class_labels



				def       snake_case    (     self					:	Dict						):
						__lowercase				:		Dict												=				MaskaFormerConfig(
						    hidden_size=self.hidden_dim    ,   )
						__lowercase				:		str												=				self.num_queries
						__lowercase				:		List[str]												=				self.num_labels

						__lowercase				:		Optional[Any]												=				[1, 1, 1, 1]
						__lowercase				:		Dict												=				self.num_channels

						__lowercase				:		Dict												=				6_4
						__lowercase				:		int												=				1_2_8
						__lowercase				:		Optional[int]												=				self.hidden_dim
						__lowercase				:		Union[str, Any]												=				self.hidden_dim
						__lowercase				:		List[Any]												=				self.hidden_dim
						return config



				def       snake_case    (     self					:	Optional[Any]						):
						__lowercase						,__lowercase						,__lowercase						,__lowercase						,__lowercase				:		Optional[int]												=				self.prepare_config_and_inputs()
						__lowercase				:		Any												=				{"pixel_values": pixel_values, "pixel_mask": pixel_mask}
						return config, inputs_dict



				def       snake_case    (     self					:	Union[str, Any]    ,   lowercase__					:	Any    ,   lowercase__					:	Union[str, Any]						):
						__lowercase				:		str												=				output.encoder_hidden_states
						__lowercase				:		List[str]												=				output.pixel_decoder_hidden_states
						__lowercase				:		Dict												=				output.transformer_decoder_hidden_states

						self.parent.assertTrue(len(lowerCamelCase_						)    ,   len(config.backbone_config.depths						)						)
						self.parent.assertTrue(len(lowerCamelCase_						)    ,   len(config.backbone_config.depths						)						)
						self.parent.assertTrue(len(lowerCamelCase_						)    ,   config.decoder_layers						)



				def       snake_case    (     self					:	Optional[int]    ,   lowercase__					:	str    ,   lowercase__					:	int    ,   lowercase__					:	int    ,   lowercase__					:	Optional[Any]=False						):
						with torch.no_grad():
								__lowercase				:		Any												=				MaskaFormerModel(config=lowerCamelCase_						)
								model.to(lowerCamelCase_						)
								model.eval()

								__lowercase				:		Tuple												=				model(pixel_values=lowerCamelCase_    ,   pixel_mask=lowerCamelCase_						)
								__lowercase				:		Tuple												=				model(lowerCamelCase_    ,   output_hidden_states=lowerCamelCase_						)

						self.parent.assertEqual(
						    output.transformer_decoder_last_hidden_state.shape    ,   (self.batch_size, self.num_queries, self.hidden_dim)    ,   )
						# let's ensure the other two hidden state exists
						self.parent.assertTrue(output.pixel_decoder_last_hidden_state is not None						)
						self.parent.assertTrue(output.encoder_last_hidden_state is not None						)

						if output_hidden_states:
								self.check_output_hidden_state(lowerCamelCase_    ,   lowerCamelCase_						)



				def       snake_case    (     self					:	Union[str, Any]    ,   lowercase__					:	Tuple    ,   lowercase__					:	Union[str, Any]    ,   lowercase__					:	Dict    ,   lowercase__					:	List[Any]    ,   lowercase__					:	int						):
						__lowercase				:		Any												=				MaskaFormerForUniversalSegmentation(config=lowerCamelCase_						)
						model.to(lowerCamelCase_						)
						model.eval()

						def comm_check_on_output(lowercase__					:	Union[str, Any]						):
								# let's still check that all the required stuff is there
								self.parent.assertTrue(result.transformer_decoder_last_hidden_state is not None						)
								self.parent.assertTrue(result.pixel_decoder_last_hidden_state is not None						)
								self.parent.assertTrue(result.encoder_last_hidden_state is not None						)
								# okay, now we need to check the logits shape
								# due to the encoder compression, masks have a //4 spatial size
								self.parent.assertEqual(
								    result.masks_queries_logits.shape    ,   (self.batch_size, self.num_queries, self.min_size // 4, self.max_size // 4)    ,   )
								# + 1 for null class
								self.parent.assertEqual(
								    result.class_queries_logits.shape    ,   (self.batch_size, self.num_queries, self.num_labels + 1)						)

						with torch.no_grad():
								__lowercase				:		List[str]												=				model(pixel_values=lowerCamelCase_    ,   pixel_mask=lowerCamelCase_						)
								__lowercase				:		Dict												=				model(lowerCamelCase_						)

								comm_check_on_output(lowerCamelCase_						)

								__lowercase				:		str												=				model(
								    pixel_values=lowerCamelCase_    ,   pixel_mask=lowerCamelCase_    ,   mask_labels=lowerCamelCase_    ,   class_labels=lowerCamelCase_						)

						comm_check_on_output(lowerCamelCase_						)

						self.parent.assertTrue(result.loss is not None						)
						self.parent.assertEqual(result.loss.shape    ,   torch.Size([1]						)						)





@require_torch
class       lowerCAmelCase__       (			a__  ,			a__  ,			unittest.TestCase    ):


				"""simple docstring"""





				__UpperCAmelCase :     Tuple       =      (MaskaFormerModel, MaskaFormerForUniversalSegmentation) if is_torch_available() else ()
				__UpperCAmelCase :     Any       =      {"feature-extraction": MaskaFormerModel} if is_torch_available() else {}

				__UpperCAmelCase :     Union[str, Any]       =      False
				__UpperCAmelCase :     str       =      False
				__UpperCAmelCase :     List[Any]       =      False
				__UpperCAmelCase :     Dict       =      False



				def       snake_case    (     self					:	List[str]						):
						__lowercase				:		Optional[Any]												=				MaskaFormerModelTester(self						)
						__lowercase				:		int												=				ConfigTester(self    ,   config_class=lowerCamelCase_    ,   has_text_modality=lowerCamelCase_						)



				def       snake_case    (     self					:	Union[str, Any]						):
						self.config_tester.run_common_tests()



				def       snake_case    (     self					:	Union[str, Any]						):
						__lowercase						,__lowercase				:		Optional[int]												=				self.model_tester.prepare_config_and_inputs_for_common()
						self.model_tester.create_and_check_maskaformer_model(lowerCamelCase_    ,   **lowerCamelCase_    ,   output_hidden_states=lowerCamelCase_						)



				def       snake_case    (     self					:	Optional[Any]						):
						__lowercase				:		Any												=				self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_maskaformer_instance_segmentation_head_model(*lowerCamelCase_						)



				@unittest.skip(reason="Mask2Former does not use inputs_embeds"						)
				def       snake_case    (     self					:	Optional[Any]						):
						pass



				@unittest.skip(reason="Mask2Former does not have a get_input_embeddings method"						)
				def       snake_case    (     self					:	int						):
						pass



				@unittest.skip(reason="Mask2Former is not a generative model"						)
				def       snake_case    (     self					:	Optional[int]						):
						pass



				@unittest.skip(reason="Mask2Former does not use token embeddings"						)
				def       snake_case    (     self					:	str						):
						pass



				@require_torch_multi_gpu
				@unittest.skip(
				    reason="Mask2Former has some layers using `add_module` which doesn\'t work well with `nn.DataParallel`"						)
				def       snake_case    (     self					:	str						):
						pass



				@unittest.skip("Will be fixed soon by reducing the size of the model used for common tests."						)
				def       snake_case    (     self					:	Any						):
						pass



				def       snake_case    (     self					:	List[str]						):
						__lowercase						,__lowercase				:		str												=				self.model_tester.prepare_config_and_inputs_for_common()

						for model_class in self.all_model_classes:
								__lowercase				:		List[str]												=				model_class(lowerCamelCase_						)
								__lowercase				:		Any												=				inspect.signature(model.forward						)
								# signature.parameters is an OrderedDict => so arg_names order is deterministic
								__lowercase				:		Any												=				[*signature.parameters.keys()]

								__lowercase				:		int												=				["pixel_values"]
								self.assertListEqual(arg_names[:1]    ,   lowerCamelCase_						)



				@slow
				def       snake_case    (     self					:	List[Any]						):
						for model_name in ["facebook/mask2former-swin-small-coco-instance"]:
								__lowercase				:		Dict												=				MaskaFormerModel.from_pretrained(lowerCamelCase_						)
								self.assertIsNotNone(lowerCamelCase_						)



				def       snake_case    (     self					:	Tuple						):
						__lowercase				:		Tuple												=				(self.model_tester.min_size,) * 2
						__lowercase				:		int												=				{
						    "pixel_values": torch.randn((2, 3, *size)    ,   device=lowerCamelCase_						),
						    "mask_labels": torch.randn((2, 1_0, *size)    ,   device=lowerCamelCase_						),
						    "class_labels": torch.zeros(2    ,   1_0    ,   device=lowerCamelCase_						).long(),
						}
						__lowercase				:		Dict												=				self.model_tester.get_config()

						__lowercase				:		Optional[Any]												=				MaskaFormerForUniversalSegmentation(lowerCamelCase_						).to(lowerCamelCase_						)
						__lowercase				:		Any												=				model(**lowerCamelCase_						)
						self.assertTrue(outputs.loss is not None						)



				def       snake_case    (     self					:	Tuple						):
						__lowercase						,__lowercase				:		int												=				self.model_tester.prepare_config_and_inputs_for_common()
						self.model_tester.create_and_check_maskaformer_model(lowerCamelCase_    ,   **lowerCamelCase_    ,   output_hidden_states=lowerCamelCase_						)



				def       snake_case    (     self					:	int						):
						__lowercase						,__lowercase				:		str												=				self.model_tester.prepare_config_and_inputs_for_common()

						for model_class in self.all_model_classes:
								__lowercase				:		int												=				model_class(lowerCamelCase_						).to(lowerCamelCase_						)
								__lowercase				:		int												=				model(**lowerCamelCase_    ,   output_attentions=lowerCamelCase_						)
								self.assertTrue(outputs.attentions is not None						)



				def       snake_case    (     self					:	int						):
						if not self.model_tester.is_training:
								return

						__lowercase				:		List[str]												=				self.all_model_classes[1]
						__lowercase						,__lowercase						,__lowercase						,__lowercase						,__lowercase				:		Optional[Any]												=				self.model_tester.prepare_config_and_inputs()

						__lowercase				:		Optional[int]												=				model_class(lowerCamelCase_						)
						model.to(lowerCamelCase_						)
						model.train()

						__lowercase				:		Optional[Any]												=				model(lowerCamelCase_    ,   mask_labels=lowerCamelCase_    ,   class_labels=lowerCamelCase_						).loss
						loss.backward()



				def       snake_case    (     self					:	List[str]						):
						__lowercase				:		Optional[int]												=				self.all_model_classes[1]
						__lowercase						,__lowercase						,__lowercase						,__lowercase						,__lowercase				:		Optional[Any]												=				self.model_tester.prepare_config_and_inputs()
						__lowercase				:		Optional[int]												=				True
						__lowercase				:		Dict												=				True

						__lowercase				:		List[Any]												=				model_class(lowerCamelCase_						).to(lowerCamelCase_						)
						model.train()

						__lowercase				:		Optional[Any]												=				model(lowerCamelCase_    ,   mask_labels=lowerCamelCase_    ,   class_labels=lowerCamelCase_						)

						__lowercase				:		Tuple												=				outputs.encoder_hidden_states[0]
						encoder_hidden_states.retain_grad()

						__lowercase				:		Optional[Any]												=				outputs.pixel_decoder_hidden_states[0]
						pixel_decoder_hidden_states.retain_grad()

						__lowercase				:		List[str]												=				outputs.transformer_decoder_hidden_states[0]
						transformer_decoder_hidden_states.retain_grad()

						__lowercase				:		Dict												=				outputs.attentions[0]
						attentions.retain_grad()

						outputs.loss.backward(retain_graph=lowerCamelCase_						)

						self.assertIsNotNone(encoder_hidden_states.grad						)
						self.assertIsNotNone(pixel_decoder_hidden_states.grad						)
						self.assertIsNotNone(transformer_decoder_hidden_states.grad						)
						self.assertIsNotNone(attentions.grad						)





__A   :  List[Any]					=      1e-4

def 						snake_case__       (					)			->Dict:






		"""simple docstring"""


		__lowercase				:		Any												=				Image.open("./tests/fixtures/tests_samples/COCO/000000039769.png"				)
		return image





@require_vision
@slow
class       lowerCAmelCase__       (			unittest.TestCase    ):


				"""simple docstring"""





				@cached_property
				def       snake_case    (     self					:	Optional[int]						):
						return "facebook/mask2former-swin-small-coco-instance"



				@cached_property
				def       snake_case    (     self					:	Union[str, Any]						):
						return MaskaFormerImageProcessor.from_pretrained(self.model_checkpoints						) if is_vision_available() else None



				def       snake_case    (     self					:	Dict						):
						__lowercase				:		List[Any]												=				MaskaFormerModel.from_pretrained(self.model_checkpoints						).to(lowerCamelCase_						)
						__lowercase				:		str												=				self.default_image_processor
						__lowercase				:		Dict												=				prepare_img()
						__lowercase				:		str												=				image_processor(lowerCamelCase_    ,   return_tensors="pt"						).to(lowerCamelCase_						)
						__lowercase				:		Tuple												=				inputs["pixel_values"].shape
						# check size is divisible by 32
						self.assertTrue((inputs_shape[-1] % 3_2) == 0 and (inputs_shape[-2] % 3_2) == 0						)
						# check size
						self.assertEqual(lowerCamelCase_    ,   (1, 3, 3_8_4, 3_8_4)						)

						with torch.no_grad():
								__lowercase				:		List[str]												=				model(**lowerCamelCase_						)

						__lowercase				:		str												=				torch.tensor(
						    [[-0.2_7_9_0, -1.0_7_1_7, -1.1_6_6_8], [-0.5_1_2_8, -0.3_1_2_8, -0.4_9_8_7], [-0.5_8_3_2, 0.1_9_7_1, -0.0_1_9_7]]						).to(lowerCamelCase_						)
						self.assertTrue(
						    torch.allclose(
						        outputs.encoder_last_hidden_state[0, 0, :3, :3]    ,   lowerCamelCase_    ,   atol=lowerCamelCase_						)						)

						__lowercase				:		str												=				torch.tensor(
						    [[0.8_9_7_3, 1.1_8_4_7, 1.1_7_7_6], [1.1_9_3_4, 1.5_0_4_0, 1.5_1_2_8], [1.1_1_5_3, 1.4_4_8_6, 1.4_9_5_1]]						).to(lowerCamelCase_						)
						self.assertTrue(
						    torch.allclose(
						        outputs.pixel_decoder_last_hidden_state[0, 0, :3, :3]    ,   lowerCamelCase_    ,   atol=lowerCamelCase_						)						)

						__lowercase				:		str												=				torch.tensor(
						    [[2.1_1_5_2, 1.7_0_0_0, -0.8_6_0_3], [1.5_8_0_8, 1.8_0_0_4, -0.9_3_5_3], [1.6_0_4_3, 1.7_4_9_5, -0.5_9_9_9]]						).to(lowerCamelCase_						)
						self.assertTrue(
						    torch.allclose(
						        outputs.transformer_decoder_last_hidden_state[0, :3, :3]    ,   lowerCamelCase_    ,   atol=lowerCamelCase_						)						)



				def       snake_case    (     self					:	Any						):
						__lowercase				:		str												=				MaskaFormerForUniversalSegmentation.from_pretrained(self.model_checkpoints						).to(lowerCamelCase_						).eval()
						__lowercase				:		Dict												=				self.default_image_processor
						__lowercase				:		List[str]												=				prepare_img()
						__lowercase				:		Union[str, Any]												=				image_processor(lowerCamelCase_    ,   return_tensors="pt"						).to(lowerCamelCase_						)
						__lowercase				:		Any												=				inputs["pixel_values"].shape
						# check size is divisible by 32
						self.assertTrue((inputs_shape[-1] % 3_2) == 0 and (inputs_shape[-2] % 3_2) == 0						)
						# check size
						self.assertEqual(lowerCamelCase_    ,   (1, 3, 3_8_4, 3_8_4)						)

						with torch.no_grad():
								__lowercase				:		List[Any]												=				model(**lowerCamelCase_						)
						# masks_queries_logits
						__lowercase				:		List[Any]												=				outputs.masks_queries_logits
						self.assertEqual(
						    masks_queries_logits.shape    ,   (1, model.config.num_queries, inputs_shape[-2] // 4, inputs_shape[-1] // 4)						)
						__lowercase				:		str												=				[
						    [-8.7_8_3_9, -9.0_0_5_6, -8.8_1_2_1],
						    [-7.4_1_0_4, -7.0_3_1_3, -6.5_4_0_1],
						    [-6.6_1_0_5, -6.3_4_2_7, -6.4_6_7_5],
						]
						__lowercase				:		Any												=				torch.tensor(lowerCamelCase_						).to(lowerCamelCase_						)
						self.assertTrue(torch.allclose(masks_queries_logits[0, 0, :3, :3]    ,   lowerCamelCase_    ,   atol=lowerCamelCase_						)						)
						# class_queries_logits
						__lowercase				:		Tuple												=				outputs.class_queries_logits
						self.assertEqual(class_queries_logits.shape    ,   (1, model.config.num_queries, model.config.num_labels + 1)						)
						__lowercase				:		Union[str, Any]												=				torch.tensor(
						    [
						        [1.8_3_2_4, -8.0_8_3_5, -4.1_9_2_2],
						        [0.8_4_5_0, -9.0_0_5_0, -3.6_0_5_3],
						        [0.3_0_4_5, -7.7_2_9_3, -3.0_2_7_5],
						    ]						).to(lowerCamelCase_						)
						self.assertTrue(torch.allclose(outputs.class_queries_logits[0, :3, :3]    ,   lowerCamelCase_    ,   atol=lowerCamelCase_						)						)



				def       snake_case    (     self					:	List[str]						):
						__lowercase				:		Union[str, Any]												=				MaskaFormerForUniversalSegmentation.from_pretrained(self.model_checkpoints						).to(lowerCamelCase_						).eval()
						__lowercase				:		int												=				self.default_image_processor

						__lowercase				:		Optional[Any]												=				image_processor(
						    [np.zeros((3, 8_0_0, 1_3_3_3)						), np.zeros((3, 8_0_0, 1_3_3_3)						)]    ,   segmentation_maps=[np.zeros((3_8_4, 3_8_4)						).astype(np.floataa						), np.zeros((3_8_4, 3_8_4)						).astype(np.floataa						)]    ,   return_tensors="pt"    ,   )

						__lowercase				:		Tuple												=				inputs["pixel_values"].to(lowerCamelCase_						)
						__lowercase				:		Optional[Any]												=				[el.to(lowerCamelCase_						) for el in inputs["mask_labels"]]
						__lowercase				:		List[str]												=				[el.to(lowerCamelCase_						) for el in inputs["class_labels"]]

						with torch.no_grad():
								__lowercase				:		Optional[Any]												=				model(**lowerCamelCase_						)

						self.assertTrue(outputs.loss is not None						)






"""simple docstring"""







import os
import sys
import unittest


__A   :  Optional[Any]					=      os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
sys.path.append(os.path.join(git_repo_path, 'utils'))

import check_dummies  # noqa: E402
from check_dummies import create_dummy_files, create_dummy_object, find_backend, read_init  # noqa: E402


# Align TRANSFORMERS_PATH in check_dummies with the current path
__A   :  Optional[Any]					=      os.path.join(git_repo_path, 'src', 'diffusers')




class       lowerCAmelCase__       (			unittest.TestCase    ):


				"""simple docstring"""





				def       snake_case    (     self					:	str						):
						__lowercase				:		int												=				find_backend("    if not is_torch_available():"						)
						self.assertEqual(lowercase__    ,   "torch"						)

						# backend_with_underscore = find_backend("    if not is_tensorflow_text_available():")
						# self.assertEqual(backend_with_underscore, "tensorflow_text")

						__lowercase				:		int												=				find_backend("    if not (is_torch_available() and is_transformers_available()):"						)
						self.assertEqual(lowercase__    ,   "torch_and_transformers"						)

						# double_backend_with_underscore = find_backend(
						#    "    if not (is_sentencepiece_available() and is_tensorflow_text_available()):"
						# )
						# self.assertEqual(double_backend_with_underscore, "sentencepiece_and_tensorflow_text")

						__lowercase				:		str												=				find_backend(
						    "    if not (is_torch_available() and is_transformers_available() and is_onnx_available()):"						)
						self.assertEqual(lowercase__    ,   "torch_and_transformers_and_onnx"						)



				def       snake_case    (     self					:	Any						):
						__lowercase				:		List[Any]												=				read_init()
						# We don't assert on the exact list of keys to allow for smooth grow of backend-specific objects
						self.assertIn("torch"    ,   lowercase__						)
						self.assertIn("torch_and_transformers"    ,   lowercase__						)
						self.assertIn("flax_and_transformers"    ,   lowercase__						)
						self.assertIn("torch_and_transformers_and_onnx"    ,   lowercase__						)

						# Likewise, we can't assert on the exact content of a key
						self.assertIn("UNet2DModel"    ,   objects["torch"]						)
						self.assertIn("FlaxUNet2DConditionModel"    ,   objects["flax"]						)
						self.assertIn("StableDiffusionPipeline"    ,   objects["torch_and_transformers"]						)
						self.assertIn("FlaxStableDiffusionPipeline"    ,   objects["flax_and_transformers"]						)
						self.assertIn("LMSDiscreteScheduler"    ,   objects["torch_and_scipy"]						)
						self.assertIn("OnnxStableDiffusionPipeline"    ,   objects["torch_and_transformers_and_onnx"]						)



				def       snake_case    (     self					:	Dict						):
						__lowercase				:		Tuple												=				create_dummy_object("CONSTANT"    ,   "'torch'"						)
						self.assertEqual(lowercase__    ,   "\nCONSTANT = None\n"						)

						__lowercase				:		Union[str, Any]												=				create_dummy_object("function"    ,   "'torch'"						)
						self.assertEqual(
						    lowercase__    ,   "\ndef function(*args, **kwargs):\n    requires_backends(function, 'torch')\n"						)

						__lowercase				:		Tuple												=				"\nclass FakeClass(metaclass=DummyObject):\n    _backends = 'torch'\n\n    def __init__(self, *args, **kwargs):\n        requires_backends(self, 'torch')\n\n    @classmethod\n    def from_config(cls, *args, **kwargs):\n        requires_backends(cls, 'torch')\n\n    @classmethod\n    def from_pretrained(cls, *args, **kwargs):\n        requires_backends(cls, 'torch')\n"
						__lowercase				:		Dict												=				create_dummy_object("FakeClass"    ,   "'torch'"						)
						self.assertEqual(lowercase__    ,   lowercase__						)



				def       snake_case    (     self					:	List[Any]						):
						__lowercase				:		Optional[int]												=				"# This file is autogenerated by the command `make fix-copies`, do not edit.\nfrom ..utils import DummyObject, requires_backends\n\n\nCONSTANT = None\n\n\ndef function(*args, **kwargs):\n    requires_backends(function, [\"torch\"])\n\n\nclass FakeClass(metaclass=DummyObject):\n    _backends = [\"torch\"]\n\n    def __init__(self, *args, **kwargs):\n        requires_backends(self, [\"torch\"])\n\n    @classmethod\n    def from_config(cls, *args, **kwargs):\n        requires_backends(cls, [\"torch\"])\n\n    @classmethod\n    def from_pretrained(cls, *args, **kwargs):\n        requires_backends(cls, [\"torch\"])\n"
						__lowercase				:		List[str]												=				create_dummy_files({"torch": ["CONSTANT", "function", "FakeClass"]}						)
						self.assertEqual(dummy_files["torch"]    ,   lowercase__						)
