"""simple docstring"""





import inspect
import unittest

from datasets import load_dataset
from packaging import version

from transformers import BeitConfig
from transformers.models.auto import get_values
from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device
from transformers.utils import cached_property, is_torch_available, is_vision_available

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


if is_torch_available():
				import torch
				from torch import nn

				from transformers import (
				    MODEL_MAPPING,
				    BeitForImageClassification,
				    BeitForMaskedImageModeling,
				    BeitForSemanticSegmentation,
				    BeitModel,
				)
				from transformers.models.beit.modeling_beit import BEIT_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
				import PIL
				from PIL import Image

				from transformers import BeitImageProcessor
class  _snake_case     :






						def __init__(       self      :			str							,					UpperCAmelCase      :			Union[str, Any]							,					UpperCAmelCase      :			Optional[int]=100							,					UpperCAmelCase      :			Dict=13							,					UpperCAmelCase      :			int=30							,					UpperCAmelCase      :			Optional[Any]=2							,					UpperCAmelCase      :			List[Any]=3							,					UpperCAmelCase      :			Optional[Any]=True							,					UpperCAmelCase      :			Any=True							,					UpperCAmelCase      :			Optional[Any]=32							,					UpperCAmelCase      :			Tuple=4							,					UpperCAmelCase      :			Tuple=4							,					UpperCAmelCase      :			Tuple=37							,					UpperCAmelCase      :			Union[str, Any]="gelu"							,					UpperCAmelCase      :			int=0.1							,					UpperCAmelCase      :			str=0.1							,					UpperCAmelCase      :			Any=10							,					UpperCAmelCase      :			Union[str, Any]=0.0_2							,					UpperCAmelCase      :			List[Any]=3							,					UpperCAmelCase      :			Optional[Any]=None							,					UpperCAmelCase      :			List[Any]=[0, 1, 2, 3]							,					):
													__lowerCamelCase					:		Optional[int]		   =     parent
													__lowerCamelCase					:		Dict		   =     100
													__lowerCamelCase					:		List[Any]		   =     batch_size
													__lowerCamelCase					:		str		   =     image_size
													__lowerCamelCase					:		str		   =     patch_size
													__lowerCamelCase					:		Optional[int]		   =     num_channels
													__lowerCamelCase					:		str		   =     is_training
													__lowerCamelCase					:		Union[str, Any]		   =     use_labels
													__lowerCamelCase					:		Union[str, Any]		   =     hidden_size
													__lowerCamelCase					:		Dict		   =     num_hidden_layers
													__lowerCamelCase					:		Dict		   =     num_attention_heads
													__lowerCamelCase					:		int		   =     intermediate_size
													__lowerCamelCase					:		Union[str, Any]		   =     hidden_act
													__lowerCamelCase					:		str		   =     hidden_dropout_prob
													__lowerCamelCase					:		str		   =     attention_probs_dropout_prob
													__lowerCamelCase					:		List[str]		   =     type_sequence_label_size
													__lowerCamelCase					:		List[Any]		   =     initializer_range
													__lowerCamelCase					:		str		   =     scope
													__lowerCamelCase					:		str		   =     out_indices
													__lowerCamelCase					:		Optional[int]		   =     num_labels

													# in BeiT, the seq length equals the number of patches + 1 (we add 1 for the [CLS] token)
													__lowerCamelCase					:		List[Any]		   =     (image_size // patch_size) ** 2
													__lowerCamelCase					:		Any		   =     num_patches + 1






						def       lowerCamelCase__     (       self      :			List[str]    ):
													__lowerCamelCase					:		Dict		   =     floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]    )

													__lowerCamelCase					:		Optional[Any]		   =     None
													__lowerCamelCase					:		Any		   =     None
													if self.use_labels:
																				__lowerCamelCase					:		Dict		   =     ids_tensor([self.batch_size]							,					self.type_sequence_label_size    )
																				__lowerCamelCase					:		Dict		   =     ids_tensor([self.batch_size, self.image_size, self.image_size]							,					self.num_labels    )

													__lowerCamelCase					:		int		   =     self.get_config()

													return config, pixel_values, labels, pixel_labels






						def       lowerCamelCase__     (       self      :			Optional[int]    ):
													return BeitConfig(
													    vocab_size=self.vocab_size							,					image_size=self.image_size							,					patch_size=self.patch_size							,					num_channels=self.num_channels							,					hidden_size=self.hidden_size							,					num_hidden_layers=self.num_hidden_layers							,					num_attention_heads=self.num_attention_heads							,					intermediate_size=self.intermediate_size							,					hidden_act=self.hidden_act							,					hidden_dropout_prob=self.hidden_dropout_prob							,					attention_probs_dropout_prob=self.attention_probs_dropout_prob							,					is_decoder=UpperCAmelCase							,					initializer_range=self.initializer_range							,					out_indices=self.out_indices							,					)






						def       lowerCamelCase__     (       self      :			Union[str, Any]							,					UpperCAmelCase      :			List[str]							,					UpperCAmelCase      :			Optional[int]							,					UpperCAmelCase      :			str							,					UpperCAmelCase      :			str    ):
													__lowerCamelCase					:		Dict		   =     BeitModel(config=UpperCAmelCase    )
													model.to(UpperCAmelCase    )
													model.eval()
													__lowerCamelCase					:		Optional[Any]		   =     model(UpperCAmelCase    )
													self.parent.assertEqual(result.last_hidden_state.shape							,					(self.batch_size, self.seq_length, self.hidden_size)    )






						def       lowerCamelCase__     (       self      :			Tuple							,					UpperCAmelCase      :			Any							,					UpperCAmelCase      :			int							,					UpperCAmelCase      :			Dict							,					UpperCAmelCase      :			Optional[int]    ):
													__lowerCamelCase					:		Optional[Any]		   =     BeitForMaskedImageModeling(config=UpperCAmelCase    )
													model.to(UpperCAmelCase    )
													model.eval()
													__lowerCamelCase					:		Union[str, Any]		   =     model(UpperCAmelCase    )
													self.parent.assertEqual(result.logits.shape							,					(self.batch_size, self.seq_length - 1, self.vocab_size)    )






						def       lowerCamelCase__     (       self      :			int							,					UpperCAmelCase      :			Tuple							,					UpperCAmelCase      :			List[str]							,					UpperCAmelCase      :			str							,					UpperCAmelCase      :			Dict    ):
													__lowerCamelCase					:		int		   =     self.type_sequence_label_size
													__lowerCamelCase					:		Tuple		   =     BeitForImageClassification(UpperCAmelCase    )
													model.to(UpperCAmelCase    )
													model.eval()
													__lowerCamelCase					:		int		   =     model(UpperCAmelCase							,					labels=UpperCAmelCase    )
													self.parent.assertEqual(result.logits.shape							,					(self.batch_size, self.type_sequence_label_size)    )

													# test greyscale images
													__lowerCamelCase					:		Optional[int]		   =     1
													__lowerCamelCase					:		List[str]		   =     BeitForImageClassification(UpperCAmelCase    )
													model.to(UpperCAmelCase    )
													model.eval()

													__lowerCamelCase					:		Any		   =     floats_tensor([self.batch_size, 1, self.image_size, self.image_size]    )
													__lowerCamelCase					:		Dict		   =     model(UpperCAmelCase							,					labels=UpperCAmelCase    )
													self.parent.assertEqual(result.logits.shape							,					(self.batch_size, self.type_sequence_label_size)    )






						def       lowerCamelCase__     (       self      :			Union[str, Any]							,					UpperCAmelCase      :			Any							,					UpperCAmelCase      :			int							,					UpperCAmelCase      :			List[Any]							,					UpperCAmelCase      :			Any    ):
													__lowerCamelCase					:		List[str]		   =     self.num_labels
													__lowerCamelCase					:		Optional[int]		   =     BeitForSemanticSegmentation(UpperCAmelCase    )
													model.to(UpperCAmelCase    )
													model.eval()
													__lowerCamelCase					:		Optional[Any]		   =     model(UpperCAmelCase    )
													self.parent.assertEqual(
													    result.logits.shape							,					(self.batch_size, self.num_labels, self.image_size * 2, self.image_size * 2)    )
													__lowerCamelCase					:		List[Any]		   =     model(UpperCAmelCase							,					labels=UpperCAmelCase    )
													self.parent.assertEqual(
													    result.logits.shape							,					(self.batch_size, self.num_labels, self.image_size * 2, self.image_size * 2)    )







						def       lowerCamelCase__     (       self      :			int    ):
													__lowerCamelCase					:		List[Any]		   =     self.prepare_config_and_inputs()
													__lowerCamelCase   ,  __lowerCamelCase   ,  __lowerCamelCase   ,  __lowerCamelCase					:		Optional[Any]		   =     config_and_inputs
													__lowerCamelCase					:		Optional[Any]		   =     {"pixel_values": pixel_values}
													return config, inputs_dict

@require_torch
class  _snake_case     (					a__				, a__				, unittest.TestCase		):
						snake_case__			  =			(
						    (BeitModel, BeitForImageClassification, BeitForMaskedImageModeling, BeitForSemanticSegmentation)
						    if is_torch_available()
						    else ()
						)
						snake_case__			  =			(
						    {
						        "feature-extraction": BeitModel,
						        "image-classification": BeitForImageClassification,
						        "image-segmentation": BeitForSemanticSegmentation,
						    }
						    if is_torch_available()
						    else {}
						)

						snake_case__			  =			False
						snake_case__			  =			False
						snake_case__			  =			False






						def       lowerCamelCase__     (       self      :			int    ):
													__lowerCamelCase					:		Optional[int]		   =     BeitModelTester(self    )
													__lowerCamelCase					:		Optional[int]		   =     ConfigTester(self							,					config_class=UpperCAmelCase							,					has_text_modality=UpperCAmelCase							,					hidden_size=37    )






						def       lowerCamelCase__     (       self      :			Optional[Any]    ):
													self.config_tester.run_common_tests()






						@unittest.skip(reason="BEiT does not use inputs_embeds"    )
						def       lowerCamelCase__     (       self      :			Any    ):
													pass






						@require_torch_multi_gpu
						@unittest.skip(reason="BEiT has some layers using `add_module` which doesn't work well with `nn.DataParallel`"    )
						def       lowerCamelCase__     (       self      :			List[Any]    ):
													pass






						def       lowerCamelCase__     (       self      :			List[str]    ):
													__lowerCamelCase   ,  __lowerCamelCase					:		Tuple		   =     self.model_tester.prepare_config_and_inputs_for_common()

													for model_class in self.all_model_classes:
																				__lowerCamelCase					:		List[Any]		   =     model_class(UpperCAmelCase    )
																				self.assertIsInstance(model.get_input_embeddings()							,					(nn.Module)    )
																				__lowerCamelCase					:		List[str]		   =     model.get_output_embeddings()
																				self.assertTrue(x is None or isinstance(UpperCAmelCase							,					nn.Linear    )    )






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

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

																				__lowerCamelCase					:		Optional[int]		   =     ["pixel_values"]
																				self.assertListEqual(arg_names[:1]							,					UpperCAmelCase    )






						def       lowerCamelCase__     (       self      :			int    ):
													__lowerCamelCase					:		Optional[int]		   =     self.model_tester.prepare_config_and_inputs()
													self.model_tester.create_and_check_model(*UpperCAmelCase    )






						def       lowerCamelCase__     (       self      :			Optional[int]    ):
													__lowerCamelCase					:		Tuple		   =     self.model_tester.prepare_config_and_inputs()
													self.model_tester.create_and_check_for_masked_lm(*UpperCAmelCase    )






						def       lowerCamelCase__     (       self      :			Optional[int]    ):
													__lowerCamelCase					:		List[Any]		   =     self.model_tester.prepare_config_and_inputs()
													self.model_tester.create_and_check_for_image_classification(*UpperCAmelCase    )






						def       lowerCamelCase__     (       self      :			Any    ):
													__lowerCamelCase					:		Dict		   =     self.model_tester.prepare_config_and_inputs()
													self.model_tester.create_and_check_for_semantic_segmentation(*UpperCAmelCase    )






						def       lowerCamelCase__     (       self      :			Union[str, Any]    ):
													if not self.model_tester.is_training:
																				return

													__lowerCamelCase   ,  __lowerCamelCase					:		str		   =     self.model_tester.prepare_config_and_inputs_for_common()
													__lowerCamelCase					:		Optional[int]		   =     True

													for model_class in self.all_model_classes:
																				# we don't test BeitForMaskedImageModeling
																				if model_class in [*get_values(UpperCAmelCase    ), BeitForMaskedImageModeling]:
																											continue

																				__lowerCamelCase					:		str		   =     model_class(UpperCAmelCase    )
																				model.to(UpperCAmelCase    )
																				model.train()
																				__lowerCamelCase					:		Optional[Any]		   =     self._prepare_for_class(UpperCAmelCase							,					UpperCAmelCase							,					return_labels=UpperCAmelCase    )
																				__lowerCamelCase					:		int		   =     model(**UpperCAmelCase    ).loss
																				loss.backward()






						def       lowerCamelCase__     (       self      :			Any    ):
													__lowerCamelCase   ,  __lowerCamelCase					:		int		   =     self.model_tester.prepare_config_and_inputs_for_common()
													if not self.model_tester.is_training:
																				return

													__lowerCamelCase					:		Dict		   =     False
													__lowerCamelCase					:		Any		   =     True

													for model_class in self.all_model_classes:
																				# we don't test BeitForMaskedImageModeling
																				if (
																				    model_class in [*get_values(UpperCAmelCase    ), BeitForMaskedImageModeling]
																				    or not model_class.supports_gradient_checkpointing
																				):
																											continue

																				__lowerCamelCase					:		List[Any]		   =     model_class(UpperCAmelCase    )
																				model.gradient_checkpointing_enable()
																				model.to(UpperCAmelCase    )
																				model.train()
																				__lowerCamelCase					:		str		   =     self._prepare_for_class(UpperCAmelCase							,					UpperCAmelCase							,					return_labels=UpperCAmelCase    )
																				__lowerCamelCase					:		Optional[int]		   =     model(**UpperCAmelCase    ).loss
																				loss.backward()






						def       lowerCamelCase__     (       self      :			List[Any]    ):
													__lowerCamelCase   ,  __lowerCamelCase					:		str		   =     self.model_tester.prepare_config_and_inputs_for_common()

													__lowerCamelCase					:		Optional[int]		   =     _config_zero_init(UpperCAmelCase    )
													for model_class in self.all_model_classes:
																				__lowerCamelCase					:		Union[str, Any]		   =     model_class(config=UpperCAmelCase    )
																				for name, param in model.named_parameters():
																											# we skip lambda parameters as these require special initial values
																											# determined by config.layer_scale_init_value
																											if "lambda" in name:
																																		continue
																											if param.requires_grad:
																																		self.assertIn(
																																		    ((param.data.mean() * 1E9).round() / 1E9).item()							,					[0.0, 1.0]							,					msg=F"""Parameter {name} of model {model_class} seems not properly initialized"""							,					)







						@slow
						def       lowerCamelCase__     (       self      :			List[str]    ):
													for model_name in BEIT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																				__lowerCamelCase					:		Any		   =     BeitModel.from_pretrained(UpperCAmelCase    )
																				self.assertIsNotNone(UpperCAmelCase    )


def    lowercase_   (   ) ->      List[str]:



							'''simple docstring'''

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







@require_torch
@require_vision
class  _snake_case     (					unittest.TestCase		):






						@cached_property
						def       lowerCamelCase__     (       self      :			str    ):
													return BeitImageProcessor.from_pretrained("microsoft/beit-base-patch16-224"    ) if is_vision_available() else None






						@slow
						def       lowerCamelCase__     (       self      :			List[Any]    ):
													__lowerCamelCase					:		Any		   =     BeitForMaskedImageModeling.from_pretrained("microsoft/beit-base-patch16-224-pt22k"    ).to(UpperCAmelCase    )

													__lowerCamelCase					:		Union[str, Any]		   =     self.default_image_processor
													__lowerCamelCase					:		Optional[Any]		   =     prepare_img()
													__lowerCamelCase					:		int		   =     image_processor(images=UpperCAmelCase							,					return_tensors="pt"    ).pixel_values.to(UpperCAmelCase    )

													# prepare bool_masked_pos
													__lowerCamelCase					:		List[Any]		   =     torch.ones((1, 196)							,					dtype=torch.bool    ).to(UpperCAmelCase    )

													# forward pass
													with torch.no_grad():
																				__lowerCamelCase					:		Tuple		   =     model(pixel_values=UpperCAmelCase							,					bool_masked_pos=UpperCAmelCase    )
													__lowerCamelCase					:		Union[str, Any]		   =     outputs.logits

													# verify the logits
													__lowerCamelCase					:		str		   =     torch.Size((1, 196, 8192)    )
													self.assertEqual(logits.shape							,					UpperCAmelCase    )

													__lowerCamelCase					:		List[Any]		   =     torch.tensor(
													    [[-3.2_4_3_7, 0.5_0_7_2, -1_3.9_1_7_4], [-3.2_4_5_6, 0.4_9_4_8, -1_3.9_4_0_1], [-3.2_0_3_3, 0.5_1_2_1, -1_3.8_5_5_0]]    ).to(UpperCAmelCase    )

													self.assertTrue(torch.allclose(logits[bool_masked_pos][:3, :3]							,					UpperCAmelCase							,					atol=1E-2    )    )






						@slow
						def       lowerCamelCase__     (       self      :			Optional[Any]    ):
													__lowerCamelCase					:		Optional[Any]		   =     BeitForImageClassification.from_pretrained("microsoft/beit-base-patch16-224"    ).to(UpperCAmelCase    )

													__lowerCamelCase					:		Union[str, Any]		   =     self.default_image_processor
													__lowerCamelCase					:		Optional[Any]		   =     prepare_img()
													__lowerCamelCase					:		Optional[int]		   =     image_processor(images=UpperCAmelCase							,					return_tensors="pt"    ).to(UpperCAmelCase    )

													# forward pass
													with torch.no_grad():
																				__lowerCamelCase					:		Optional[int]		   =     model(**UpperCAmelCase    )
													__lowerCamelCase					:		Optional[Any]		   =     outputs.logits

													# verify the logits
													__lowerCamelCase					:		Tuple		   =     torch.Size((1, 1000)    )
													self.assertEqual(logits.shape							,					UpperCAmelCase    )

													__lowerCamelCase					:		str		   =     torch.tensor([-1.2_3_8_5, -1.0_9_8_7, -1.0_1_0_8]    ).to(UpperCAmelCase    )

													self.assertTrue(torch.allclose(logits[0, :3]							,					UpperCAmelCase							,					atol=1E-4    )    )

													__lowerCamelCase					:		Any		   =     281
													self.assertEqual(logits.argmax(-1    ).item()							,					UpperCAmelCase    )






						@slow
						def       lowerCamelCase__     (       self      :			List[Any]    ):
													__lowerCamelCase					:		Dict		   =     BeitForImageClassification.from_pretrained("microsoft/beit-large-patch16-224-pt22k-ft22k"    ).to(
													    UpperCAmelCase    )

													__lowerCamelCase					:		Optional[Any]		   =     self.default_image_processor
													__lowerCamelCase					:		Tuple		   =     prepare_img()
													__lowerCamelCase					:		str		   =     image_processor(images=UpperCAmelCase							,					return_tensors="pt"    ).to(UpperCAmelCase    )

													# forward pass
													with torch.no_grad():
																				__lowerCamelCase					:		List[str]		   =     model(**UpperCAmelCase    )
													__lowerCamelCase					:		Optional[Any]		   =     outputs.logits

													# verify the logits
													__lowerCamelCase					:		Optional[int]		   =     torch.Size((1, 21841)    )
													self.assertEqual(logits.shape							,					UpperCAmelCase    )

													__lowerCamelCase					:		List[str]		   =     torch.tensor([1.6_8_8_1, -0.2_7_8_7, 0.5_9_0_1]    ).to(UpperCAmelCase    )

													self.assertTrue(torch.allclose(logits[0, :3]							,					UpperCAmelCase							,					atol=1E-4    )    )

													__lowerCamelCase					:		Optional[int]		   =     2396
													self.assertEqual(logits.argmax(-1    ).item()							,					UpperCAmelCase    )






						@slow
						def       lowerCamelCase__     (       self      :			List[str]    ):
													__lowerCamelCase					:		Optional[int]		   =     BeitForSemanticSegmentation.from_pretrained("microsoft/beit-base-finetuned-ade-640-640"    )
													__lowerCamelCase					:		List[Any]		   =     model.to(UpperCAmelCase    )

													__lowerCamelCase					:		Union[str, Any]		   =     BeitImageProcessor(do_resize=UpperCAmelCase							,					size=640							,					do_center_crop=UpperCAmelCase    )

													__lowerCamelCase					:		Union[str, Any]		   =     load_dataset("hf-internal-testing/fixtures_ade20k"							,					split="test"    )
													__lowerCamelCase					:		Optional[int]		   =     Image.open(ds[0]["file"]    )
													__lowerCamelCase					:		Optional[int]		   =     image_processor(images=UpperCAmelCase							,					return_tensors="pt"    ).to(UpperCAmelCase    )

													# forward pass
													with torch.no_grad():
																				__lowerCamelCase					:		Optional[Any]		   =     model(**UpperCAmelCase    )
													__lowerCamelCase					:		Tuple		   =     outputs.logits

													# verify the logits
													__lowerCamelCase					:		int		   =     torch.Size((1, 150, 160, 160)    )
													self.assertEqual(logits.shape							,					UpperCAmelCase    )

													__lowerCamelCase					:		Any		   =     version.parse(PIL.__version__    ) < version.parse("9.0.0"    )

													if is_pillow_less_than_a:
																				__lowerCamelCase					:		Tuple		   =     torch.tensor(
																				    [
																				        [[-4.9_2_2_5, -2.3_9_5_4, -3.0_5_2_2], [-2.8_8_2_2, -1.0_0_4_6, -1.7_5_6_1], [-2.9_5_4_9, -1.3_2_2_8, -2.1_3_4_7]],
																				        [[-5.8_1_6_8, -3.4_1_2_9, -4.0_7_7_8], [-3.8_6_5_1, -2.2_2_1_4, -3.0_2_7_7], [-3.8_3_5_6, -2.4_6_4_3, -3.3_5_3_5]],
																				        [[-0.0_0_7_8, 3.9_9_5_2, 4.0_7_5_4], [2.9_8_5_6, 4.6_9_4_4, 5.0_0_3_5], [3.2_4_1_3, 4.7_8_1_3, 4.9_9_6_9]],
																				    ]							,					device=UpperCAmelCase							,					)
													else:
																				__lowerCamelCase					:		Optional[int]		   =     torch.tensor(
																				    [
																				        [[-4.8_9_6_0, -2.3_6_8_8, -3.0_3_5_5], [-2.8_4_7_8, -0.9_8_3_6, -1.7_4_1_8], [-2.9_4_4_9, -1.3_3_3_2, -2.1_4_5_6]],
																				        [[-5.8_0_8_1, -3.4_1_2_4, -4.1_0_0_6], [-3.8_5_6_1, -2.2_0_8_1, -3.0_3_2_3], [-3.8_3_6_5, -2.4_6_0_1, -3.3_6_6_9]],
																				        [[-0.0_3_0_9, 3.9_8_6_8, 4.0_5_4_0], [2.9_6_4_0, 4.6_8_7_7, 4.9_9_7_6], [3.2_0_8_1, 4.7_6_9_0, 4.9_9_4_2]],
																				    ]							,					device=UpperCAmelCase							,					)

													self.assertTrue(torch.allclose(logits[0, :3, :3, :3]							,					UpperCAmelCase							,					atol=1E-4    )    )







						@slow
						def       lowerCamelCase__     (       self      :			Union[str, Any]    ):
													__lowerCamelCase					:		Dict		   =     BeitForSemanticSegmentation.from_pretrained("microsoft/beit-base-finetuned-ade-640-640"    )
													__lowerCamelCase					:		Optional[int]		   =     model.to(UpperCAmelCase    )

													__lowerCamelCase					:		List[str]		   =     BeitImageProcessor(do_resize=UpperCAmelCase							,					size=640							,					do_center_crop=UpperCAmelCase    )

													__lowerCamelCase					:		List[Any]		   =     load_dataset("hf-internal-testing/fixtures_ade20k"							,					split="test"    )
													__lowerCamelCase					:		Union[str, Any]		   =     Image.open(ds[0]["file"]    )
													__lowerCamelCase					:		Tuple		   =     image_processor(images=UpperCAmelCase							,					return_tensors="pt"    ).to(UpperCAmelCase    )

													# forward pass
													with torch.no_grad():
																				__lowerCamelCase					:		str		   =     model(**UpperCAmelCase    )

													__lowerCamelCase					:		Optional[int]		   =     outputs.logits.detach().cpu()

													__lowerCamelCase					:		int		   =     image_processor.post_process_semantic_segmentation(outputs=UpperCAmelCase							,					target_sizes=[(500, 300)]    )
													__lowerCamelCase					:		Union[str, Any]		   =     torch.Size((500, 300)    )
													self.assertEqual(segmentation[0].shape							,					UpperCAmelCase    )

													__lowerCamelCase					:		str		   =     image_processor.post_process_semantic_segmentation(outputs=UpperCAmelCase    )
													__lowerCamelCase					:		Optional[Any]		   =     torch.Size((160, 160)    )
													self.assertEqual(segmentation[0].shape							,					UpperCAmelCase    )
"""simple docstring"""





import math
from datetime import datetime, timedelta


def    lowercase_   (   _lowerCamelCase:	int      ) ->      datetime:



							'''simple docstring'''

							__lowerCamelCase					:		List[Any]		   =     year % 19
							__lowerCamelCase					:		List[str]		   =     year % 4
							__lowerCamelCase					:		Dict		   =     year % 7
							__lowerCamelCase					:		Optional[Any]		   =     math.floor(year / 100      )
							__lowerCamelCase					:		Tuple		   =     math.floor((13 + 8 * leap_day_inhibits) / 25      )
							__lowerCamelCase					:		List[str]		   =     leap_day_inhibits / 4
							__lowerCamelCase					:		Optional[Any]		   =     (
							    15 - lunar_orbit_correction + leap_day_inhibits - leap_day_reinstall_number
							) % 30
							__lowerCamelCase					:		Union[str, Any]		   =     (4 + leap_day_inhibits - leap_day_reinstall_number) % 7

							# days to be added to March 21
							__lowerCamelCase					:		Union[str, Any]		   =     (19 * metonic_cycle + secular_moon_shift) % 30

							# PHM -> Paschal Full Moon
							__lowerCamelCase					:		List[Any]		   =     (
							    2 * julian_leap_year
							    + 4 * non_leap_year
							    + 6 * days_to_add
							    + century_starting_point
							) % 7

							if days_to_add == 29 and days_from_phm_to_sunday == 6:
														return datetime(_lowerCamelCase						,   4						,   19      )
							elif days_to_add == 28 and days_from_phm_to_sunday == 6:
														return datetime(_lowerCamelCase						,   4						,   18      )
							else:
														return datetime(_lowerCamelCase						,   3						,   22      ) + timedelta(
														    days=int(days_to_add + days_from_phm_to_sunday      )      )


if __name__ == "__main__":
				for year in (1994, 2000, 2010, 2021, 2023):
								__A  =				'''will be''' if year > datetime.now().year else '''was'''
								print(F"""Easter in {year} {tense} {gauss_easter(year)}""")