




'''simple docstring'''







from __future__ import annotations

# Define the Gravitational Constant G and the function
_lowerCamelCase							:						Any								=  6.6743e-11  # unit of G : m^3 * kg^-1 * s^-2






def 		_lowercase		(	lowercase_						,							lowercase_						,							lowercase_						,							lowercase_  ):



		'''simple docstring'''







		_snake_case	       =       mass_a * mass_a

		if (force, mass_a, mass_a, distance).count(0  ) != 1:
				raise ValueError("One and only one argument must be 0"  )
		if force < 0:
				raise ValueError("Gravitational force can not be negative"  )
		if distance < 0:
				raise ValueError("Distance can not be negative"  )
		if mass_a < 0 or mass_a < 0:
				raise ValueError("Mass can not be negative"  )
		if force == 0:
				_snake_case	       =       GRAVITATIONAL_CONSTANT * product_of_mass / (distance**2)
				return {"force": force}
		elif mass_a == 0:
				_snake_case	       =       (force) * (distance**2) / (GRAVITATIONAL_CONSTANT * mass_a)
				return {"mass_1": mass_a}
		elif mass_a == 0:
				_snake_case	       =       (force) * (distance**2) / (GRAVITATIONAL_CONSTANT * mass_a)
				return {"mass_2": mass_a}
		elif distance == 0:
				_snake_case	       =       (GRAVITATIONAL_CONSTANT * product_of_mass / (force)) ** 0.5
				return {"distance": distance}
		raise ValueError("One and only one argument must be 0"  )


# Run doctest
if __name__ == "__main__":
						import doctest

						doctest.testmod()







"""simple docstring"""

import collections
import inspect
import unittest

from transformers import SwinConfig
from transformers.testing_utils import require_torch, require_vision, slow, torch_device
from transformers.utils import cached_property, is_torch_available, is_vision_available

from ...test_backbone_common import BackboneTesterMixin
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 SwinBackbone, SwinForImageClassification, SwinForMaskedImageModeling, SwinModel
					from transformers.models.swin.modeling_swin import SWIN_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
					from PIL import Image

					from transformers import AutoImageProcessor






class        _lowercase   :




	def __init__( self		, UpperCAmelCase_		, UpperCAmelCase_=13		, UpperCAmelCase_=32		, UpperCAmelCase_=2		, UpperCAmelCase_=3		, UpperCAmelCase_=16		, UpperCAmelCase_=[1, 2, 1]		, UpperCAmelCase_=[2, 2, 4]		, UpperCAmelCase_=2		, UpperCAmelCase_=2.0		, UpperCAmelCase_=True		, UpperCAmelCase_=0.0		, UpperCAmelCase_=0.0		, UpperCAmelCase_=0.1		, UpperCAmelCase_="gelu"		, UpperCAmelCase_=False		, UpperCAmelCase_=True		, UpperCAmelCase_=0.02		, UpperCAmelCase_=1E-5		, UpperCAmelCase_=True		, UpperCAmelCase_=None		, UpperCAmelCase_=True		, UpperCAmelCase_=10		, UpperCAmelCase_=8		, UpperCAmelCase_=["stage1", "stage2"]		, UpperCAmelCase_=[1, 2]		, )		->							Union[str, Any]:
			lowerCamelCase     :			Any		=    parent
			lowerCamelCase     :			List[Any]		=    batch_size
			lowerCamelCase     :			str		=    image_size
			lowerCamelCase     :			int		=    patch_size
			lowerCamelCase     :			int		=    num_channels
			lowerCamelCase     :			Optional[Any]		=    embed_dim
			lowerCamelCase     :			List[Any]		=    depths
			lowerCamelCase     :			Optional[Any]		=    num_heads
			lowerCamelCase     :			str		=    window_size
			lowerCamelCase     :			Optional[int]		=    mlp_ratio
			lowerCamelCase     :			Tuple		=    qkv_bias
			lowerCamelCase     :			List[str]		=    hidden_dropout_prob
			lowerCamelCase     :			Optional[int]		=    attention_probs_dropout_prob
			lowerCamelCase     :			List[Any]		=    drop_path_rate
			lowerCamelCase     :			Dict		=    hidden_act
			lowerCamelCase     :			List[Any]		=    use_absolute_embeddings
			lowerCamelCase     :			Optional[int]		=    patch_norm
			lowerCamelCase     :			int		=    layer_norm_eps
			lowerCamelCase     :			Dict		=    initializer_range
			lowerCamelCase     :			List[str]		=    is_training
			lowerCamelCase     :			Tuple		=    scope
			lowerCamelCase     :			List[Any]		=    use_labels
			lowerCamelCase     :			int		=    type_sequence_label_size
			lowerCamelCase     :			Optional[Any]		=    encoder_stride
			lowerCamelCase     :			Optional[Any]		=    out_features
			lowerCamelCase     :			Union[str, Any]		=    out_indices




	def 			_UpperCamelCase    ( self					)		->							int:
			lowerCamelCase     :			str		=    floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]					)

			lowerCamelCase     :			int		=    None
			if self.use_labels:
					lowerCamelCase     :			str		=    ids_tensor([self.batch_size]		, self.type_sequence_label_size					)

			lowerCamelCase     :			Optional[int]		=    self.get_config()

			return config, pixel_values, labels




	def 			_UpperCamelCase    ( self					)		->							Optional[int]:
			return SwinConfig(
			    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 			_UpperCamelCase    ( self		, UpperCAmelCase_		, UpperCAmelCase_		, UpperCAmelCase_					)		->							int:
			lowerCamelCase     :			str		=    SwinModel(config=UpperCAmelCase_					)
			model.to(UpperCAmelCase_					)
			model.eval()
			lowerCamelCase     :			Optional[Any]		=    model(UpperCAmelCase_					)

			lowerCamelCase     :			str		=    ((config.image_size // config.patch_size) ** 2) // (4 ** (len(config.depths					) - 1))
			lowerCamelCase     :			Tuple		=    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 			_UpperCamelCase    ( self		, UpperCAmelCase_		, UpperCAmelCase_		, UpperCAmelCase_					)		->							int:
			lowerCamelCase     :			Dict		=    SwinBackbone(config=UpperCAmelCase_					)
			model.to(UpperCAmelCase_					)
			model.eval()
			lowerCamelCase     :			Union[str, Any]		=    model(UpperCAmelCase_					)

			# verify hidden states
			self.parent.assertEqual(len(result.feature_maps					)		, len(config.out_features					)					)
			self.parent.assertListEqual(list(result.feature_maps[0].shape					)		, [self.batch_size, model.channels[0], 16, 16]					)

			# verify channels
			self.parent.assertEqual(len(model.channels					)		, len(config.out_features					)					)

			# verify backbone works with out_features=None
			lowerCamelCase     :			Any		=    None
			lowerCamelCase     :			Optional[int]		=    SwinBackbone(config=UpperCAmelCase_					)
			model.to(UpperCAmelCase_					)
			model.eval()
			lowerCamelCase     :			Dict		=    model(UpperCAmelCase_					)

			# verify feature maps
			self.parent.assertEqual(len(result.feature_maps					)		, 1					)
			self.parent.assertListEqual(list(result.feature_maps[0].shape					)		, [self.batch_size, model.channels[-1], 4, 4]					)

			# verify channels
			self.parent.assertEqual(len(model.channels					)		, 1					)




	def 			_UpperCamelCase    ( self		, UpperCAmelCase_		, UpperCAmelCase_		, UpperCAmelCase_					)		->							Union[str, Any]:
			lowerCamelCase     :			Dict		=    SwinForMaskedImageModeling(config=UpperCAmelCase_					)
			model.to(UpperCAmelCase_					)
			model.eval()
			lowerCamelCase     :			Tuple		=    model(UpperCAmelCase_					)
			self.parent.assertEqual(
			    result.logits.shape		, (self.batch_size, self.num_channels, self.image_size, self.image_size)					)

			# test greyscale images
			lowerCamelCase     :			Optional[int]		=    1
			lowerCamelCase     :			int		=    SwinForMaskedImageModeling(UpperCAmelCase_					)
			model.to(UpperCAmelCase_					)
			model.eval()

			lowerCamelCase     :			Tuple		=    floats_tensor([self.batch_size, 1, self.image_size, self.image_size]					)
			lowerCamelCase     :			List[Any]		=    model(UpperCAmelCase_					)
			self.parent.assertEqual(result.logits.shape		, (self.batch_size, 1, self.image_size, self.image_size)					)




	def 			_UpperCamelCase    ( self		, UpperCAmelCase_		, UpperCAmelCase_		, UpperCAmelCase_					)		->							str:
			lowerCamelCase     :			Optional[int]		=    self.type_sequence_label_size
			lowerCamelCase     :			Optional[int]		=    SwinForImageClassification(UpperCAmelCase_					)
			model.to(UpperCAmelCase_					)
			model.eval()
			lowerCamelCase     :			Dict		=    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[Any]		=    SwinForImageClassification(UpperCAmelCase_					)
			model.to(UpperCAmelCase_					)
			model.eval()

			lowerCamelCase     :			str		=    floats_tensor([self.batch_size, 1, self.image_size, self.image_size]					)
			lowerCamelCase     :			Union[str, Any]		=    model(UpperCAmelCase_					)
			self.parent.assertEqual(result.logits.shape		, (self.batch_size, self.type_sequence_label_size)					)




	def 			_UpperCamelCase    ( self					)		->							List[Any]:
			lowerCamelCase     :			Optional[Any]		=    self.prepare_config_and_inputs()
			(
			    (
			    lowerCamelCase
			)	,    (
			    lowerCamelCase
			)	,    (
			    lowerCamelCase
			)	,    
			)     :			Optional[Any]		=    config_and_inputs
			lowerCamelCase     :			Union[str, Any]		=    {'pixel_values': pixel_values}
			return config, inputs_dict






@require_torch
class        _lowercase   (				__UpperCAmelCase				,       __UpperCAmelCase				,       unittest.TestCase		):
	lowercase_        =	(
	    (
	        SwinModel,
	        SwinBackbone,
	        SwinForImageClassification,
	        SwinForMaskedImageModeling,
	    )
	    if is_torch_available()
	    else ()
	)
	lowercase_        =	(
	    {'feature-extraction': SwinModel, 'image-classification': SwinForImageClassification}
	    if is_torch_available()
	    else {}
	)
	lowercase_        =	True

	lowercase_        =	False
	lowercase_        =	False
	lowercase_        =	False




	def 			_UpperCamelCase    ( self					)		->							Tuple:
			lowerCamelCase     :			Optional[Any]		=    SwinModelTester(self					)
			lowerCamelCase     :			Any		=    ConfigTester(self		, config_class=UpperCAmelCase_		, embed_dim=37					)




	def 			_UpperCamelCase    ( self					)		->							Tuple:
			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 			_UpperCamelCase    ( self					)		->							Optional[Any]:
			return




	def 			_UpperCamelCase    ( self					)		->							Optional[Any]:
			lowerCamelCase     :			str		=    self.model_tester.prepare_config_and_inputs()
			self.model_tester.create_and_check_model(*UpperCAmelCase_					)




	@unittest.skip(reason='Got `CUDA error: misaligned address` with PyTorch 2.0.0.'					)
	def 			_UpperCamelCase    ( self					)		->							List[str]:
			pass




	def 			_UpperCamelCase    ( self					)		->							Optional[int]:
			super().test_training_gradient_checkpointing()




	def 			_UpperCamelCase    ( self					)		->							List[str]:
			lowerCamelCase     :			Tuple		=    self.model_tester.prepare_config_and_inputs()
			self.model_tester.create_and_check_backbone(*UpperCAmelCase_					)




	def 			_UpperCamelCase    ( self					)		->							Tuple:
			lowerCamelCase     :			Dict		=    self.model_tester.prepare_config_and_inputs()
			self.model_tester.create_and_check_for_masked_image_modeling(*UpperCAmelCase_					)




	def 			_UpperCamelCase    ( self					)		->							Any:
			lowerCamelCase     :			List[Any]		=    self.model_tester.prepare_config_and_inputs()
			self.model_tester.create_and_check_for_image_classification(*UpperCAmelCase_					)




	@unittest.skip(reason='Swin does not use inputs_embeds'					)
	def 			_UpperCamelCase    ( self					)		->							List[str]:
			pass




	@unittest.skip(reason='Swin Transformer does not use feedforward chunking'					)
	def 			_UpperCamelCase    ( self					)		->							Union[str, Any]:
			pass




	def 			_UpperCamelCase    ( self					)		->							List[str]:
			lowerCamelCase	,    lowerCamelCase     :			Dict		=    self.model_tester.prepare_config_and_inputs_for_common()

			for model_class in self.all_model_classes:
					lowerCamelCase     :			Optional[int]		=    model_class(UpperCAmelCase_					)
					self.assertIsInstance(model.get_input_embeddings()		, (nn.Module)					)
					lowerCamelCase     :			str		=    model.get_output_embeddings()
					self.assertTrue(x is None or isinstance(UpperCAmelCase_		, nn.Linear					)					)




	def 			_UpperCamelCase    ( self					)		->							Union[str, Any]:
			lowerCamelCase	,    lowerCamelCase     :			List[str]		=    self.model_tester.prepare_config_and_inputs_for_common()

			for model_class in self.all_model_classes:
					lowerCamelCase     :			Dict		=    model_class(UpperCAmelCase_					)
					lowerCamelCase     :			Optional[int]		=    inspect.signature(model.forward					)
					# signature.parameters is an OrderedDict => so arg_names order is deterministic
					lowerCamelCase     :			Dict		=    [*signature.parameters.keys()]

					lowerCamelCase     :			Tuple		=    ['pixel_values']
					self.assertListEqual(arg_names[:1]		, UpperCAmelCase_					)




	def 			_UpperCamelCase    ( self					)		->							Optional[Any]:
			lowerCamelCase	,    lowerCamelCase     :			List[Any]		=    self.model_tester.prepare_config_and_inputs_for_common()
			lowerCamelCase     :			List[Any]		=    True

			for model_class in self.all_model_classes:
					lowerCamelCase     :			Optional[int]		=    True
					lowerCamelCase     :			int		=    False
					lowerCamelCase     :			Dict		=    True
					lowerCamelCase     :			Optional[Any]		=    model_class(UpperCAmelCase_					)
					model.to(UpperCAmelCase_					)
					model.eval()
					with torch.no_grad():
							lowerCamelCase     :			Any		=    model(**self._prepare_for_class(UpperCAmelCase_		, UpperCAmelCase_					)					)
					lowerCamelCase     :			List[Any]		=    outputs.attentions
					lowerCamelCase     :			int		=    len(self.model_tester.depths					)
					self.assertEqual(len(UpperCAmelCase_					)		, UpperCAmelCase_					)

					# check that output_attentions also work using config
					del inputs_dict["output_attentions"]
					lowerCamelCase     :			List[str]		=    True
					lowerCamelCase     :			Dict		=    config.window_size**2
					lowerCamelCase     :			str		=    model_class(UpperCAmelCase_					)
					model.to(UpperCAmelCase_					)
					model.eval()
					with torch.no_grad():
							lowerCamelCase     :			str		=    model(**self._prepare_for_class(UpperCAmelCase_		, UpperCAmelCase_					)					)
					lowerCamelCase     :			Optional[int]		=    outputs.attentions
					self.assertEqual(len(UpperCAmelCase_					)		, UpperCAmelCase_					)

					self.assertListEqual(
					    list(attentions[0].shape[-3:]					)		, [self.model_tester.num_heads[0], window_size_squared, window_size_squared]		, )
					lowerCamelCase     :			List[Any]		=    len(UpperCAmelCase_					)

					# Check attention is always last and order is fine
					lowerCamelCase     :			Dict		=    True
					lowerCamelCase     :			Optional[Any]		=    True
					lowerCamelCase     :			Optional[int]		=    model_class(UpperCAmelCase_					)
					model.to(UpperCAmelCase_					)
					model.eval()
					with torch.no_grad():
							lowerCamelCase     :			Dict		=    model(**self._prepare_for_class(UpperCAmelCase_		, UpperCAmelCase_					)					)

					# also another +1 for reshaped_hidden_states
					lowerCamelCase     :			List[str]		=    1 if model_class.__name__ == 'SwinBackbone' else 2
					self.assertEqual(out_len + added_hidden_states		, len(UpperCAmelCase_					)					)

					lowerCamelCase     :			Tuple		=    outputs.attentions

					self.assertEqual(len(UpperCAmelCase_					)		, UpperCAmelCase_					)

					self.assertListEqual(
					    list(self_attentions[0].shape[-3:]					)		, [self.model_tester.num_heads[0], window_size_squared, window_size_squared]		, )




	def 			_UpperCamelCase    ( self		, UpperCAmelCase_		, UpperCAmelCase_		, UpperCAmelCase_		, UpperCAmelCase_					)		->							Tuple:
			lowerCamelCase     :			Optional[int]		=    model_class(UpperCAmelCase_					)
			model.to(UpperCAmelCase_					)
			model.eval()

			with torch.no_grad():
					lowerCamelCase     :			Tuple		=    model(**self._prepare_for_class(UpperCAmelCase_		, UpperCAmelCase_					)					)

			lowerCamelCase     :			List[str]		=    outputs.hidden_states

			lowerCamelCase     :			Dict		=    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
			lowerCamelCase     :			Tuple		=    (
			    config.patch_size
			    if isinstance(config.patch_size		, collections.abc.Iterable					)
			    else (config.patch_size, config.patch_size)
			)

			lowerCamelCase     :			Dict		=    (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]		, )

			if not model_class.__name__ == "SwinBackbone":
					lowerCamelCase     :			Any		=    outputs.reshaped_hidden_states
					self.assertEqual(len(UpperCAmelCase_					)		, UpperCAmelCase_					)

					lowerCamelCase	,    lowerCamelCase	,    lowerCamelCase	,    lowerCamelCase     :			List[Any]		=    reshaped_hidden_states[0].shape
					lowerCamelCase     :			Any		=    (
					    reshaped_hidden_states[0].view(UpperCAmelCase_		, UpperCAmelCase_		, height * width					).permute(0		, 2		, 1					)
					)
					self.assertListEqual(
					    list(reshaped_hidden_states.shape[-2:]					)		, [num_patches, self.model_tester.embed_dim]		, )




	def 			_UpperCamelCase    ( self					)		->							int:
			lowerCamelCase	,    lowerCamelCase     :			Any		=    self.model_tester.prepare_config_and_inputs_for_common()

			lowerCamelCase     :			List[str]		=    (
			    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:
					lowerCamelCase     :			str		=    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"]
					lowerCamelCase     :			str		=    True

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




	def 			_UpperCamelCase    ( self					)		->							Tuple:
			lowerCamelCase	,    lowerCamelCase     :			Tuple		=    self.model_tester.prepare_config_and_inputs_for_common()
			lowerCamelCase     :			str		=    3

			lowerCamelCase     :			Union[str, 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)
			)
			lowerCamelCase     :			Any		=    (
			    config.patch_size
			    if isinstance(config.patch_size		, collections.abc.Iterable					)
			    else (config.patch_size, config.patch_size)
			)

			lowerCamelCase     :			Tuple		=    image_size[0] + patch_size[0] - (image_size[0] % patch_size[0])
			lowerCamelCase     :			Dict		=    image_size[1] + patch_size[1] - (image_size[1] % patch_size[1])

			for model_class in self.all_model_classes:
					lowerCamelCase     :			int		=    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"]
					lowerCamelCase     :			List[str]		=    True
					self.check_hidden_states_output(UpperCAmelCase_		, UpperCAmelCase_		, UpperCAmelCase_		, (padded_height, padded_width)					)




	@slow
	def 			_UpperCamelCase    ( self					)		->							str:
			for model_name in SWIN_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
					lowerCamelCase     :			Tuple		=    SwinModel.from_pretrained(UpperCAmelCase_					)
					self.assertIsNotNone(UpperCAmelCase_					)




	def 			_UpperCamelCase    ( self					)		->							List[Any]:
			lowerCamelCase	,    lowerCamelCase     :			str		=    self.model_tester.prepare_config_and_inputs_for_common()

			lowerCamelCase     :			Dict		=    _config_zero_init(UpperCAmelCase_					)
			for model_class in self.all_model_classes:
					lowerCamelCase     :			Tuple		=    model_class(config=UpperCAmelCase_					)
					for name, param in model.named_parameters():
							if "embeddings" not in name and 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"""		, )






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




	@cached_property
	def 			_UpperCamelCase    ( self					)		->							int:
			return (
			    AutoImageProcessor.from_pretrained('microsoft/swin-tiny-patch4-window7-224'					)
			    if is_vision_available()
			    else None
			)




	@slow
	def 			_UpperCamelCase    ( self					)		->							Optional[Any]:
			lowerCamelCase     :			int		=    SwinForImageClassification.from_pretrained('microsoft/swin-tiny-patch4-window7-224'					).to(UpperCAmelCase_					)
			lowerCamelCase     :			str		=    self.default_image_processor

			lowerCamelCase     :			List[str]		=    Image.open('./tests/fixtures/tests_samples/COCO/000000039769.png'					)
			lowerCamelCase     :			Optional[int]		=    image_processor(images=UpperCAmelCase_		, return_tensors='pt'					).to(UpperCAmelCase_					)

			# forward pass
			with torch.no_grad():
					lowerCamelCase     :			Optional[Any]		=    model(**UpperCAmelCase_					)

			# verify the logits
			lowerCamelCase     :			Tuple		=    torch.Size((1, 1000)					)
			self.assertEqual(outputs.logits.shape		, UpperCAmelCase_					)
			lowerCamelCase     :			Union[str, Any]		=    torch.tensor([-0.0948, -0.6454, -0.0921]					).to(UpperCAmelCase_					)
			self.assertTrue(torch.allclose(outputs.logits[0, :3]		, UpperCAmelCase_		, atol=1E-4					)					)






@require_torch
class        _lowercase   (				unittest.TestCase				,       __UpperCAmelCase		):
	lowercase_        =	(SwinBackbone,) if is_torch_available() else ()
	lowercase_        =	SwinConfig




	def 			_UpperCamelCase    ( self					)		->							Union[str, Any]:
			lowerCamelCase     :			str		=    SwinModelTester(self					)






