




"""simple docstring"""







import collections
import inspect
import unittest
from typing import Dict, List, Tuple

from transformers import MaskFormerSwinConfig
from transformers.testing_utils import require_torch, require_torch_multi_gpu, torch_device
from transformers.utils import is_torch_available

from ...test_backbone_common import BackboneTesterMixin
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
						import torch
						from torch import nn

						from transformers import MaskFormerSwinBackbone
						from transformers.models.maskformer import MaskFormerSwinModel




class       lowerCAmelCase__       :


				"""simple docstring"""





				def __init__(     self					:	List[Any]    ,   lowercase__					:	Dict    ,   lowercase__					:	Any=1_3    ,   lowercase__					:	Dict=3_2    ,   lowercase__					:	List[Any]=2    ,   lowercase__					:	Optional[int]=3    ,   lowercase__					:	Optional[int]=1_6    ,   lowercase__					:	Dict=[1, 2, 1]    ,   lowercase__					:	List[Any]=[2, 2, 4]    ,   lowercase__					:	str=2    ,   lowercase__					:	Dict=2.0    ,   lowercase__					:	Dict=True    ,   lowercase__					:	Tuple=0.0    ,   lowercase__					:	int=0.0    ,   lowercase__					:	List[Any]=0.1    ,   lowercase__					:	Any="gelu"    ,   lowercase__					:	int=False    ,   lowercase__					:	List[Any]=True    ,   lowercase__					:	List[str]=0.0_2    ,   lowercase__					:	Union[str, Any]=1e-5    ,   lowercase__					:	Union[str, Any]=True    ,   lowercase__					:	List[Any]=None    ,   lowercase__					:	Tuple=True    ,   lowercase__					:	Optional[int]=1_0    ,   lowercase__					:	Any=8    ,   lowercase__					:	Optional[int]=["stage1", "stage2", "stage3"]    ,   lowercase__					:	str=[1, 2, 3]    ,   ):
						__lowercase				:		Optional[int]												=				parent
						__lowercase				:		List[Any]												=				batch_size
						__lowercase				:		int												=				image_size
						__lowercase				:		List[Any]												=				patch_size
						__lowercase				:		int												=				num_channels
						__lowercase				:		int												=				embed_dim
						__lowercase				:		Tuple												=				depths
						__lowercase				:		Tuple												=				num_heads
						__lowercase				:		Union[str, Any]												=				window_size
						__lowercase				:		Tuple												=				mlp_ratio
						__lowercase				:		Optional[Any]												=				qkv_bias
						__lowercase				:		Tuple												=				hidden_dropout_prob
						__lowercase				:		Tuple												=				attention_probs_dropout_prob
						__lowercase				:		List[Any]												=				drop_path_rate
						__lowercase				:		str												=				hidden_act
						__lowercase				:		str												=				use_absolute_embeddings
						__lowercase				:		Optional[int]												=				patch_norm
						__lowercase				:		Any												=				layer_norm_eps
						__lowercase				:		Any												=				initializer_range
						__lowercase				:		Any												=				is_training
						__lowercase				:		Tuple												=				scope
						__lowercase				:		List[Any]												=				use_labels
						__lowercase				:		Optional[int]												=				type_sequence_label_size
						__lowercase				:		Tuple												=				encoder_stride
						__lowercase				:		str												=				out_features
						__lowercase				:		Any												=				out_indices



				def       snake_case    (     self					:	str						):
						__lowercase				:		Union[str, Any]												=				floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]						)

						__lowercase				:		Dict												=				None
						if self.use_labels:
								__lowercase				:		Tuple												=				ids_tensor([self.batch_size]    ,   self.type_sequence_label_size						)

						__lowercase				:		Dict												=				self.get_config()

						return config, pixel_values, labels



				def       snake_case    (     self					:	Any						):
						return MaskFormerSwinConfig(
						    image_size=self.image_size    ,   patch_size=self.patch_size    ,   num_channels=self.num_channels    ,   embed_dim=self.embed_dim    ,   depths=self.depths    ,   num_heads=self.num_heads    ,   window_size=self.window_size    ,   mlp_ratio=self.mlp_ratio    ,   qkv_bias=self.qkv_bias    ,   hidden_dropout_prob=self.hidden_dropout_prob    ,   attention_probs_dropout_prob=self.attention_probs_dropout_prob    ,   drop_path_rate=self.drop_path_rate    ,   hidden_act=self.hidden_act    ,   use_absolute_embeddings=self.use_absolute_embeddings    ,   path_norm=self.patch_norm    ,   layer_norm_eps=self.layer_norm_eps    ,   initializer_range=self.initializer_range    ,   encoder_stride=self.encoder_stride    ,   out_features=self.out_features    ,   out_indices=self.out_indices    ,   )



				def       snake_case    (     self					:	str    ,   lowercase__					:	Optional[Any]    ,   lowercase__					:	List[Any]    ,   lowercase__					:	List[Any]						):
						__lowercase				:		int												=				MaskFormerSwinModel(config=UpperCAmelCase_						)
						model.to(UpperCAmelCase_						)
						model.eval()
						__lowercase				:		Tuple												=				model(UpperCAmelCase_						)

						__lowercase				:		Optional[int]												=				((config.image_size // config.patch_size) ** 2) // (4 ** (len(config.depths						) - 1))
						__lowercase				:		Union[str, Any]												=				int(config.embed_dim * 2 ** (len(config.depths						) - 1)						)

						self.parent.assertEqual(result.last_hidden_state.shape    ,   (self.batch_size, expected_seq_len, expected_dim)						)



				def       snake_case    (     self					:	Optional[int]    ,   lowercase__					:	str    ,   lowercase__					:	str    ,   lowercase__					:	Tuple						):
						__lowercase				:		List[Any]												=				MaskFormerSwinBackbone(config=UpperCAmelCase_						)
						model.to(UpperCAmelCase_						)
						model.eval()
						__lowercase				:		Any												=				model(UpperCAmelCase_						)

						# verify feature maps
						self.parent.assertEqual(len(result.feature_maps						)    ,   len(config.out_features						)						)
						self.parent.assertListEqual(list(result.feature_maps[0].shape						)    ,   [1_3, 1_6, 1_6, 1_6]						)

						# verify channels
						self.parent.assertEqual(len(model.channels						)    ,   len(config.out_features						)						)
						self.parent.assertListEqual(model.channels    ,   [1_6, 3_2, 6_4]						)

						# verify ValueError
						with self.parent.assertRaises(UpperCAmelCase_						):
								__lowercase				:		Dict												=				["stem"]
								__lowercase				:		Dict												=				MaskFormerSwinBackbone(config=UpperCAmelCase_						)



				def       snake_case    (     self					:	Any						):
						__lowercase				:		Union[str, Any]												=				self.prepare_config_and_inputs()
						__lowercase						,__lowercase						,__lowercase				:		List[str]												=				config_and_inputs
						__lowercase				:		Dict												=				{"pixel_values": pixel_values}
						return config, inputs_dict





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


				"""simple docstring"""





				__UpperCAmelCase :     Optional[Any]       =      (
				    (
				        MaskFormerSwinModel,
				        MaskFormerSwinBackbone,
				    )
				    if is_torch_available()
				    else ()
				)
				__UpperCAmelCase :     Tuple       =      {"""feature-extraction""": MaskFormerSwinModel} if is_torch_available() else {}
				__UpperCAmelCase :     Tuple       =      False
				__UpperCAmelCase :     Optional[int]       =      False
				__UpperCAmelCase :     Dict       =      False
				__UpperCAmelCase :     int       =      False
				__UpperCAmelCase :     List[str]       =      False



				def       snake_case    (     self					:	Optional[Any]						):
						__lowercase				:		Union[str, Any]												=				MaskFormerSwinModelTester(self						)
						__lowercase				:		Optional[Any]												=				ConfigTester(self    ,   config_class=UpperCAmelCase_    ,   embed_dim=3_7						)



				@require_torch_multi_gpu
				@unittest.skip(
				    reason=(
				        "`MaskFormerSwinModel` outputs `hidden_states_spatial_dimensions` which doesn't work well with"
				        " `nn.DataParallel`"
				    )						)
				def       snake_case    (     self					:	int						):
						pass



				def       snake_case    (     self					:	int						):
						self.create_and_test_config_common_properties()
						self.config_tester.create_and_test_config_to_json_string()
						self.config_tester.create_and_test_config_to_json_file()
						self.config_tester.create_and_test_config_from_and_save_pretrained()
						self.config_tester.create_and_test_config_with_num_labels()
						self.config_tester.check_config_can_be_init_without_params()
						self.config_tester.check_config_arguments_init()



				def       snake_case    (     self					:	Any						):
						return



				def       snake_case    (     self					:	List[Any]						):
						__lowercase				:		List[str]												=				self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_model(*UpperCAmelCase_						)



				def       snake_case    (     self					:	Dict						):
						__lowercase				:		List[Any]												=				self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_backbone(*UpperCAmelCase_						)



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



				@unittest.skip("Swin does not support feedforward chunking"						)
				def       snake_case    (     self					:	Any						):
						pass



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

						for model_class in self.all_model_classes:
								__lowercase				:		Tuple												=				model_class(UpperCAmelCase_						)
								self.assertIsInstance(model.get_input_embeddings()    ,   (nn.Module)						)
								__lowercase				:		Tuple												=				model.get_output_embeddings()
								self.assertTrue(x is None or isinstance(UpperCAmelCase_    ,   nn.Linear						)						)



				def       snake_case    (     self					:	Optional[Any]						):
						__lowercase						,__lowercase				:		Union[str, Any]												=				self.model_tester.prepare_config_and_inputs_for_common()

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

								__lowercase				:		List[Any]												=				["pixel_values"]
								self.assertListEqual(arg_names[:1]    ,   UpperCAmelCase_						)



				@unittest.skip(reason="MaskFormerSwin is only used as backbone and doesn't support output_attentions"						)
				def       snake_case    (     self					:	List[str]						):
						pass



				@unittest.skip(reason="MaskFormerSwin is only used as an internal backbone"						)
				def       snake_case    (     self					:	int						):
						pass



				def       snake_case    (     self					:	Dict    ,   lowercase__					:	Tuple    ,   lowercase__					:	Optional[int]    ,   lowercase__					:	Optional[Any]    ,   lowercase__					:	Optional[Any]						):
						__lowercase				:		List[Any]												=				model_class(UpperCAmelCase_						)
						model.to(UpperCAmelCase_						)
						model.eval()

						with torch.no_grad():
								__lowercase				:		List[str]												=				model(**self._prepare_for_class(UpperCAmelCase_    ,   UpperCAmelCase_						)						)

						__lowercase				:		Optional[int]												=				outputs.hidden_states

						__lowercase				:		Tuple												=				getattr(
						    self.model_tester    ,   "expected_num_hidden_layers"    ,   len(self.model_tester.depths						) + 1						)
						self.assertEqual(len(UpperCAmelCase_						)    ,   UpperCAmelCase_						)

						# Swin has a different seq_length
						__lowercase				:		Union[str, Any]												=				(
						    config.patch_size
						    if isinstance(config.patch_size    ,   collections.abc.Iterable						)
						    else (config.patch_size, config.patch_size)
						)

						__lowercase				:		Tuple												=				(image_size[1] // patch_size[1]) * (image_size[0] // patch_size[0])

						self.assertListEqual(
						    list(hidden_states[0].shape[-2:]						)    ,   [num_patches, self.model_tester.embed_dim]    ,   )



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

						__lowercase				:		Optional[Any]												=				(
						    self.model_tester.image_size
						    if isinstance(self.model_tester.image_size    ,   collections.abc.Iterable						)
						    else (self.model_tester.image_size, self.model_tester.image_size)
						)

						for model_class in self.all_model_classes:
								__lowercase				:		Tuple												=				True
								self.check_hidden_states_output(UpperCAmelCase_    ,   UpperCAmelCase_    ,   UpperCAmelCase_    ,   UpperCAmelCase_						)

								# check that output_hidden_states also work using config
								del inputs_dict["output_hidden_states"]
								__lowercase				:		Dict												=				True

								self.check_hidden_states_output(UpperCAmelCase_    ,   UpperCAmelCase_    ,   UpperCAmelCase_    ,   UpperCAmelCase_						)



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

						__lowercase				:		Any												=				(
						    self.model_tester.image_size
						    if isinstance(self.model_tester.image_size    ,   collections.abc.Iterable						)
						    else (self.model_tester.image_size, self.model_tester.image_size)
						)
						__lowercase				:		Tuple												=				(
						    config.patch_size
						    if isinstance(config.patch_size    ,   collections.abc.Iterable						)
						    else (config.patch_size, config.patch_size)
						)

						__lowercase				:		Tuple												=				image_size[0] + patch_size[0] - (image_size[0] % patch_size[0])
						__lowercase				:		Optional[Any]												=				image_size[1] + patch_size[1] - (image_size[1] % patch_size[1])

						for model_class in self.all_model_classes:
								__lowercase				:		Tuple												=				True
								self.check_hidden_states_output(UpperCAmelCase_    ,   UpperCAmelCase_    ,   UpperCAmelCase_    ,   (padded_height, padded_width)						)

								# check that output_hidden_states also work using config
								del inputs_dict["output_hidden_states"]
								__lowercase				:		Optional[int]												=				True
								self.check_hidden_states_output(UpperCAmelCase_    ,   UpperCAmelCase_    ,   UpperCAmelCase_    ,   (padded_height, padded_width)						)



				@unittest.skip(reason="MaskFormerSwin doesn't have pretrained checkpoints"						)
				def       snake_case    (     self					:	str						):
						pass



				@unittest.skip(reason="This will be fixed once MaskFormerSwin is replaced by native Swin"						)
				def       snake_case    (     self					:	Optional[int]						):
						pass



				@unittest.skip(reason="This will be fixed once MaskFormerSwin is replaced by native Swin"						)
				def       snake_case    (     self					:	int						):
						pass



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

						def set_nan_tensor_to_zero(lowercase__					:	List[Any]						):
								__lowercase				:		Optional[int]												=				0
								return t

						def check_equivalence(lowercase__					:	str    ,   lowercase__					:	List[Any]    ,   lowercase__					:	int    ,   lowercase__					:	Optional[int]={}						):
								with torch.no_grad():
										__lowercase				:		Optional[Any]												=				model(**UpperCAmelCase_    ,   return_dict=UpperCAmelCase_    ,   **UpperCAmelCase_						)
										__lowercase				:		Any												=				model(**UpperCAmelCase_    ,   return_dict=UpperCAmelCase_    ,   **UpperCAmelCase_						).to_tuple()

										def recursive_check(lowercase__					:	Any    ,   lowercase__					:	Optional[int]						):
												if isinstance(UpperCAmelCase_    ,   (List, Tuple)						):
														for tuple_iterable_value, dict_iterable_value in zip(UpperCAmelCase_    ,   UpperCAmelCase_						):
																recursive_check(UpperCAmelCase_    ,   UpperCAmelCase_						)
												elif isinstance(UpperCAmelCase_    ,   UpperCAmelCase_						):
														for tuple_iterable_value, dict_iterable_value in zip(
														    tuple_object.values()    ,   dict_object.values()						):
																recursive_check(UpperCAmelCase_    ,   UpperCAmelCase_						)
												elif tuple_object is None:
														return
												else:
														self.assertTrue(
														    torch.allclose(
														        set_nan_tensor_to_zero(UpperCAmelCase_						)    ,   set_nan_tensor_to_zero(UpperCAmelCase_						)    ,   atol=1e-5						)    ,   msg=(
														        "Tuple and dict output are not equal. Difference:"
														        f' {torch.max(torch.abs(tuple_object - dict_object						)						)}. Tuple has `nan`:'
														        f' {torch.isnan(UpperCAmelCase_						).any()} and `inf`: {torch.isinf(UpperCAmelCase_						)}. Dict has'
														        f' `nan`: {torch.isnan(UpperCAmelCase_						).any()} and `inf`: {torch.isinf(UpperCAmelCase_						)}.'
														    )    ,   )

										recursive_check(UpperCAmelCase_    ,   UpperCAmelCase_						)

						for model_class in self.all_model_classes:
								__lowercase				:		List[str]												=				model_class(UpperCAmelCase_						)
								model.to(UpperCAmelCase_						)
								model.eval()

								__lowercase				:		Optional[int]												=				self._prepare_for_class(UpperCAmelCase_    ,   UpperCAmelCase_						)
								__lowercase				:		Dict												=				self._prepare_for_class(UpperCAmelCase_    ,   UpperCAmelCase_						)
								check_equivalence(UpperCAmelCase_    ,   UpperCAmelCase_    ,   UpperCAmelCase_						)

								__lowercase				:		Any												=				self._prepare_for_class(UpperCAmelCase_    ,   UpperCAmelCase_    ,   return_labels=UpperCAmelCase_						)
								__lowercase				:		Union[str, Any]												=				self._prepare_for_class(UpperCAmelCase_    ,   UpperCAmelCase_    ,   return_labels=UpperCAmelCase_						)
								check_equivalence(UpperCAmelCase_    ,   UpperCAmelCase_    ,   UpperCAmelCase_						)

								__lowercase				:		int												=				self._prepare_for_class(UpperCAmelCase_    ,   UpperCAmelCase_						)
								__lowercase				:		Optional[int]												=				self._prepare_for_class(UpperCAmelCase_    ,   UpperCAmelCase_						)
								check_equivalence(UpperCAmelCase_    ,   UpperCAmelCase_    ,   UpperCAmelCase_    ,   {"output_hidden_states": True}						)

								__lowercase				:		Any												=				self._prepare_for_class(UpperCAmelCase_    ,   UpperCAmelCase_    ,   return_labels=UpperCAmelCase_						)
								__lowercase				:		Union[str, Any]												=				self._prepare_for_class(UpperCAmelCase_    ,   UpperCAmelCase_    ,   return_labels=UpperCAmelCase_						)
								check_equivalence(UpperCAmelCase_    ,   UpperCAmelCase_    ,   UpperCAmelCase_    ,   {"output_hidden_states": True}						)





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


				"""simple docstring"""





				__UpperCAmelCase :     Union[str, Any]       =      (MaskFormerSwinBackbone,) if is_torch_available() else ()
				__UpperCAmelCase :     Tuple       =      MaskFormerSwinConfig



				def       snake_case    (     self					:	str						):
						__lowercase				:		Union[str, Any]												=				MaskFormerSwinModelTester(self						)



				def       snake_case    (     self					:	Optional[Any]						):
						__lowercase						,__lowercase				:		Dict												=				self.model_tester.prepare_config_and_inputs_for_common()
						__lowercase				:		Dict												=				inputs_dict["pixel_values"].shape[0]

						for backbone_class in self.all_model_classes:
								__lowercase				:		Any												=				backbone_class(UpperCAmelCase_						)
								backbone.to(UpperCAmelCase_						)
								backbone.eval()

								__lowercase				:		Optional[Any]												=				backbone(**UpperCAmelCase_						)

								# Test default outputs and verify feature maps
								self.assertIsInstance(outputs.feature_maps    ,   UpperCAmelCase_						)
								self.assertTrue(len(outputs.feature_maps						) == len(backbone.channels						)						)
								for feature_map, n_channels in zip(outputs.feature_maps    ,   backbone.channels						):
										self.assertTrue(feature_map.shape[:2]    ,   (batch_size, n_channels)						)
								self.assertIsNone(outputs.hidden_states						)
								self.assertIsNone(outputs.attentions						)

								# Test output_hidden_states=True
								__lowercase				:		Dict												=				backbone(**UpperCAmelCase_    ,   output_hidden_states=UpperCAmelCase_						)
								self.assertIsNotNone(outputs.hidden_states						)
								self.assertTrue(len(outputs.hidden_states						)    ,   len(backbone.stage_names						)						)
								# We skip the stem layer
								for hidden_states, n_channels in zip(outputs.hidden_states[1:]    ,   backbone.channels						):
										for hidden_state in hidden_states:
												# Hidden states are in the format (batch_size, (height * width), n_channels)
												__lowercase						,__lowercase						,__lowercase				:		List[Any]												=				hidden_state.shape
												self.assertTrue((h_batch_size, h_n_channels)    ,   (batch_size, n_channels)						)

            # Test output_attentions=True
								if self.has_attentions:
										__lowercase				:		Optional[Any]												=				backbone(**UpperCAmelCase_    ,   output_attentions=UpperCAmelCase_						)
										self.assertIsNotNone(outputs.attentions						)






"""simple docstring"""







import unittest

from transformers.testing_utils import CaptureStdout
from transformers.tools.python_interpreter import evaluate

def 						snake_case__       (					_lowerCamelCase				)			->Dict:






		"""simple docstring"""


		return x + 2





class       lowerCAmelCase__       (			unittest.TestCase    ):


				"""simple docstring"""





				def       snake_case    (     self					:	List[str]						):
						__lowercase				:		List[Any]												=				"x = 3"
						__lowercase				:		Optional[int]												=				{}
						__lowercase				:		List[Any]												=				evaluate(lowercase__    ,   {}    ,   state=lowercase__						)
						assert result == 3
						self.assertDictEqual(lowercase__    ,   {"x": 3}						)

						__lowercase				:		Optional[int]												=				"x = y"
						__lowercase				:		Union[str, Any]												=				{"y": 5}
						__lowercase				:		str												=				evaluate(lowercase__    ,   {}    ,   state=lowercase__						)
						# evaluate returns the value of the last assignment.
						assert result == 5
						self.assertDictEqual(lowercase__    ,   {"x": 5, "y": 5}						)



				def       snake_case    (     self					:	Dict						):
						__lowercase				:		Dict												=				"y = add_two(x)"
						__lowercase				:		List[Any]												=				{"x": 3}
						__lowercase				:		Optional[int]												=				evaluate(lowercase__    ,   {"add_two": add_two}    ,   state=lowercase__						)
						assert result == 5
						self.assertDictEqual(lowercase__    ,   {"x": 3, "y": 5}						)

						# Won't work without the tool
						with CaptureStdout() as out:
								__lowercase				:		Any												=				evaluate(lowercase__    ,   {}    ,   state=lowercase__						)
						assert result is None
						assert "tried to execute add_two" in out.out



				def       snake_case    (     self					:	Any						):
						__lowercase				:		Optional[Any]												=				"x = 3"
						__lowercase				:		List[Any]												=				{}
						__lowercase				:		Dict												=				evaluate(lowercase__    ,   {}    ,   state=lowercase__						)
						assert result == 3
						self.assertDictEqual(lowercase__    ,   {"x": 3}						)



				def       snake_case    (     self					:	str						):
						__lowercase				:		Optional[int]												=				"test_dict = {'x': x, 'y': add_two(x)}"
						__lowercase				:		List[str]												=				{"x": 3}
						__lowercase				:		Tuple												=				evaluate(lowercase__    ,   {"add_two": add_two}    ,   state=lowercase__						)
						self.assertDictEqual(lowercase__    ,   {"x": 3, "y": 5}						)
						self.assertDictEqual(lowercase__    ,   {"x": 3, "test_dict": {"x": 3, "y": 5}}						)



				def       snake_case    (     self					:	int						):
						__lowercase				:		Tuple												=				"x = 3\ny = 5"
						__lowercase				:		Optional[Any]												=				{}
						__lowercase				:		List[Any]												=				evaluate(lowercase__    ,   {}    ,   state=lowercase__						)
						# evaluate returns the value of the last assignment.
						assert result == 5
						self.assertDictEqual(lowercase__    ,   {"x": 3, "y": 5}						)



				def       snake_case    (     self					:	Any						):
						__lowercase				:		str												=				"text = f'This is x: {x}.'"
						__lowercase				:		Any												=				{"x": 3}
						__lowercase				:		List[Any]												=				evaluate(lowercase__    ,   {}    ,   state=lowercase__						)
						# evaluate returns the value of the last assignment.
						assert result == "This is x: 3."
						self.assertDictEqual(lowercase__    ,   {"x": 3, "text": "This is x: 3."}						)



				def       snake_case    (     self					:	str						):
						__lowercase				:		Optional[Any]												=				"if x <= 3:\n    y = 2\nelse:\n    y = 5"
						__lowercase				:		int												=				{"x": 3}
						__lowercase				:		Optional[int]												=				evaluate(lowercase__    ,   {}    ,   state=lowercase__						)
						# evaluate returns the value of the last assignment.
						assert result == 2
						self.assertDictEqual(lowercase__    ,   {"x": 3, "y": 2}						)

						__lowercase				:		Optional[int]												=				{"x": 8}
						__lowercase				:		Union[str, Any]												=				evaluate(lowercase__    ,   {}    ,   state=lowercase__						)
						# evaluate returns the value of the last assignment.
						assert result == 5
						self.assertDictEqual(lowercase__    ,   {"x": 8, "y": 5}						)



				def       snake_case    (     self					:	Dict						):
						__lowercase				:		Optional[Any]												=				"test_list = [x, add_two(x)]"
						__lowercase				:		str												=				{"x": 3}
						__lowercase				:		Any												=				evaluate(lowercase__    ,   {"add_two": add_two}    ,   state=lowercase__						)
						self.assertListEqual(lowercase__    ,   [3, 5]						)
						self.assertDictEqual(lowercase__    ,   {"x": 3, "test_list": [3, 5]}						)



				def       snake_case    (     self					:	Optional[int]						):
						__lowercase				:		str												=				"y = x"
						__lowercase				:		str												=				{"x": 3}
						__lowercase				:		int												=				evaluate(lowercase__    ,   {}    ,   state=lowercase__						)
						assert result == 3
						self.assertDictEqual(lowercase__    ,   {"x": 3, "y": 3}						)



				def       snake_case    (     self					:	Optional[int]						):
						__lowercase				:		str												=				"test_list = [x, add_two(x)]\ntest_list[1]"
						__lowercase				:		Optional[Any]												=				{"x": 3}
						__lowercase				:		Any												=				evaluate(lowercase__    ,   {"add_two": add_two}    ,   state=lowercase__						)
						assert result == 5
						self.assertDictEqual(lowercase__    ,   {"x": 3, "test_list": [3, 5]}						)

						__lowercase				:		Tuple												=				"test_dict = {'x': x, 'y': add_two(x)}\ntest_dict['y']"
						__lowercase				:		Union[str, Any]												=				{"x": 3}
						__lowercase				:		Tuple												=				evaluate(lowercase__    ,   {"add_two": add_two}    ,   state=lowercase__						)
						assert result == 5
						self.assertDictEqual(lowercase__    ,   {"x": 3, "test_dict": {"x": 3, "y": 5}}						)



				def       snake_case    (     self					:	Dict						):
						__lowercase				:		Dict												=				"x = 0\nfor i in range(3):\n    x = i"
						__lowercase				:		str												=				{}
						__lowercase				:		int												=				evaluate(lowercase__    ,   {"range": range}    ,   state=lowercase__						)
						assert result == 2
						self.assertDictEqual(lowercase__    ,   {"x": 2, "i": 2}						)
