'''simple docstring'''

def  _lowerCAmelCase				(				__a = 10_00      )  ->      int:
     '''simple docstring'''







     return sum(i for i in range(a_      ) if i % 3 == 0 or i % 5 == 0      )


if __name__ == "__main__":
      print(f"{solution() = }")







from __future__ import annotations

import inspect
import unittest

import numpy as np

from transformers import SwinConfig
from transformers.testing_utils import require_tf, require_vision, slow, to_atuple
from transformers.utils import cached_property, is_tf_available, is_vision_available

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


if is_tf_available():
							import tensorflow as tf

							from transformers.models.swin.modeling_tf_swin import (
							    TF_SWIN_PRETRAINED_MODEL_ARCHIVE_LIST,
							    TFSwinForImageClassification,
							    TFSwinForMaskedImageModeling,
							    TFSwinModel,
							)


if is_vision_available():
							from PIL import Image

							from transformers import AutoImageProcessor




class 							__A	:





				"""simple docstring"""







				def __init__(					self				,    lowerCamelCase__				,    lowerCamelCase__=13				,    lowerCamelCase__=32				,    lowerCamelCase__=2				,    lowerCamelCase__=3				,    lowerCamelCase__=16				,    lowerCamelCase__=[1, 2, 1]				,    lowerCamelCase__=[2, 2, 4]				,    lowerCamelCase__=2				,    lowerCamelCase__=2.0				,    lowerCamelCase__=True				,    lowerCamelCase__=0.0				,    lowerCamelCase__=0.0				,    lowerCamelCase__=0.1				,    lowerCamelCase__="gelu"				,    lowerCamelCase__=False				,    lowerCamelCase__=True				,    lowerCamelCase__=0.02				,    lowerCamelCase__=1E-5				,    lowerCamelCase__=True				,    lowerCamelCase__=None				,    lowerCamelCase__=True				,    lowerCamelCase__=10				,    lowerCamelCase__=8				,    ):




									"""simple docstring"""

									__UpperCamelCase :   List[Any]									=parent
									__UpperCamelCase :   Tuple									=batch_size
									__UpperCamelCase :   str									=image_size
									__UpperCamelCase :   int									=patch_size
									__UpperCamelCase :   Dict									=num_channels
									__UpperCamelCase :   Optional[int]									=embed_dim
									__UpperCamelCase :   Dict									=depths
									__UpperCamelCase :   Tuple									=num_heads
									__UpperCamelCase :   List[str]									=window_size
									__UpperCamelCase :   Optional[int]									=mlp_ratio
									__UpperCamelCase :   Dict									=qkv_bias
									__UpperCamelCase :   Dict									=hidden_dropout_prob
									__UpperCamelCase :   Optional[int]									=attention_probs_dropout_prob
									__UpperCamelCase :   Optional[Any]									=drop_path_rate
									__UpperCamelCase :   Optional[int]									=hidden_act
									__UpperCamelCase :   Optional[Any]									=use_absolute_embeddings
									__UpperCamelCase :   Dict									=patch_norm
									__UpperCamelCase :   str									=layer_norm_eps
									__UpperCamelCase :   Dict									=initializer_range
									__UpperCamelCase :   Optional[int]									=is_training
									__UpperCamelCase :   Any									=scope
									__UpperCamelCase :   int									=use_labels
									__UpperCamelCase :   Union[str, Any]									=type_sequence_label_size
									__UpperCamelCase :   int									=encoder_stride


				def  __lowercase				(					self       ):




									"""simple docstring"""

									__UpperCamelCase :   Any									=floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]       )

									__UpperCamelCase :   List[Any]									=None
									if self.use_labels:
														__UpperCamelCase :   List[str]									=ids_tensor([self.batch_size]				,    self.type_sequence_label_size       )

									__UpperCamelCase :   List[Any]									=self.get_config()

									return config, pixel_values, labels


				def  __lowercase				(					self       ):




									"""simple docstring"""

									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				,    )


				def  __lowercase				(					self				,    lowerCamelCase__				,    lowerCamelCase__				,    lowerCamelCase__       ):




									"""simple docstring"""

									__UpperCamelCase :   List[Any]									=TFSwinModel(config=lowerCamelCase__       )
									__UpperCamelCase :   Optional[int]									=model(lowerCamelCase__       )

									__UpperCamelCase :   Tuple									=((config.image_size // config.patch_size) ** 2) // (4 ** (len(config.depths       ) - 1))
									__UpperCamelCase :   Dict									=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  __lowercase				(					self				,    lowerCamelCase__				,    lowerCamelCase__				,    lowerCamelCase__       ):




									"""simple docstring"""

									__UpperCamelCase :   Dict									=TFSwinForMaskedImageModeling(config=lowerCamelCase__       )
									__UpperCamelCase :   List[str]									=model(lowerCamelCase__       )
									self.parent.assertEqual(
									    result.logits.shape				,    (self.batch_size, self.num_channels, self.image_size, self.image_size)       )

									# test greyscale images
									__UpperCamelCase :   Dict									=1
									__UpperCamelCase :   Union[str, Any]									=TFSwinForMaskedImageModeling(lowerCamelCase__       )

									__UpperCamelCase :   Optional[Any]									=floats_tensor([self.batch_size, 1, self.image_size, self.image_size]       )
									__UpperCamelCase :   List[Any]									=model(lowerCamelCase__       )
									self.parent.assertEqual(result.logits.shape				,    (self.batch_size, 1, self.image_size, self.image_size)       )


				def  __lowercase				(					self				,    lowerCamelCase__				,    lowerCamelCase__				,    lowerCamelCase__       ):




									"""simple docstring"""

									__UpperCamelCase :   str									=self.type_sequence_label_size
									__UpperCamelCase :   Union[str, Any]									=TFSwinForImageClassification(lowerCamelCase__       )
									__UpperCamelCase :   str									=model(lowerCamelCase__				,    labels=lowerCamelCase__       )
									self.parent.assertEqual(result.logits.shape				,    (self.batch_size, self.type_sequence_label_size)       )

									# test greyscale images
									__UpperCamelCase :   Optional[Any]									=1
									__UpperCamelCase :   int									=TFSwinForImageClassification(lowerCamelCase__       )
									__UpperCamelCase :   Union[str, Any]									=floats_tensor([self.batch_size, 1, self.image_size, self.image_size]       )
									__UpperCamelCase :   List[str]									=model(lowerCamelCase__       )
									self.parent.assertEqual(result.logits.shape				,    (self.batch_size, self.type_sequence_label_size)       )







				def  __lowercase				(					self       ):




									"""simple docstring"""

									__UpperCamelCase :   Any									=self.prepare_config_and_inputs()
									__UpperCamelCase						,							__UpperCamelCase						,							__UpperCamelCase :   str									=config_and_inputs
									__UpperCamelCase :   Any									={'pixel_values': pixel_values}
									return config, inputs_dict




@require_tf
class 							__A	(     a ,	a ,	unittest.TestCase					):





				"""simple docstring"""







				UpperCamelCase__					: Tuple     					=(
				    (
				        TFSwinModel,
				        TFSwinForImageClassification,
				        TFSwinForMaskedImageModeling,
				    )
				    if is_tf_available()
				    else ()
				)
				UpperCamelCase__					: Optional[Any]     					=(
				    {"""feature-extraction""": TFSwinModel, """image-classification""": TFSwinForImageClassification}
				    if is_tf_available()
				    else {}
				)

				UpperCamelCase__					: Any     					=False
				UpperCamelCase__					: Tuple     					=False
				UpperCamelCase__					: Tuple     					=False
				UpperCamelCase__					: Tuple     					=False


				def  __lowercase				(					self       ):




									"""simple docstring"""

									__UpperCamelCase :   Dict									=TFSwinModelTester(self       )
									__UpperCamelCase :   int									=ConfigTester(self				,    config_class=lowerCamelCase__				,    embed_dim=37       )


				def  __lowercase				(					self       ):




									"""simple docstring"""

									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  __lowercase				(					self       ):




									"""simple docstring"""

									return


				def  __lowercase				(					self       ):




									"""simple docstring"""

									__UpperCamelCase :   Union[str, Any]									=self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_model(*lowerCamelCase__       )


				def  __lowercase				(					self       ):




									"""simple docstring"""

									__UpperCamelCase :   List[str]									=self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_for_masked_image_modeling(*lowerCamelCase__       )


				def  __lowercase				(					self       ):




									"""simple docstring"""

									__UpperCamelCase :   List[Any]									=self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_for_image_classification(*lowerCamelCase__       )


				@unittest.skip(reason='Swin does not use inputs_embeds'       )
				def  __lowercase				(					self       ):




									"""simple docstring"""

									pass


				def  __lowercase				(					self       ):




									"""simple docstring"""

									__UpperCamelCase						,							__UpperCamelCase :   int									=self.model_tester.prepare_config_and_inputs_for_common()

									for model_class in self.all_model_classes:
														__UpperCamelCase :   Union[str, Any]									=model_class(lowerCamelCase__       )
														self.assertIsInstance(model.get_input_embeddings()				,    tf.keras.layers.Layer       )
														__UpperCamelCase :   List[str]									=model.get_output_embeddings()
														self.assertTrue(x is None or isinstance(lowerCamelCase__				,    tf.keras.layers.Dense       )       )


				def  __lowercase				(					self       ):




									"""simple docstring"""

									__UpperCamelCase						,							__UpperCamelCase :   Optional[Any]									=self.model_tester.prepare_config_and_inputs_for_common()

									for model_class in self.all_model_classes:
														__UpperCamelCase :   Optional[int]									=model_class(lowerCamelCase__       )
														__UpperCamelCase :   List[Any]									=inspect.signature(model.call       )
														# signature.parameters is an OrderedDict => so arg_names order is deterministic
														__UpperCamelCase :   Union[str, Any]									=[*signature.parameters.keys()]

														__UpperCamelCase :   Any									=['pixel_values']
														self.assertListEqual(arg_names[:1]				,    lowerCamelCase__       )


				def  __lowercase				(					self       ):




									"""simple docstring"""

									__UpperCamelCase						,							__UpperCamelCase :   Any									=self.model_tester.prepare_config_and_inputs_for_common()
									__UpperCamelCase :   Any									=True

									for model_class in self.all_model_classes:
														__UpperCamelCase :   str									=True
														__UpperCamelCase :   str									=False
														__UpperCamelCase :   Union[str, Any]									=True
														__UpperCamelCase :   str									=model_class(lowerCamelCase__       )
														__UpperCamelCase :   List[str]									=model(**self._prepare_for_class(lowerCamelCase__				,    lowerCamelCase__       )       )
														__UpperCamelCase :   Union[str, Any]									=outputs.attentions
														__UpperCamelCase :   Optional[int]									=len(self.model_tester.depths       )
														self.assertEqual(len(lowerCamelCase__       )				,    lowerCamelCase__       )

														# check that output_attentions also work using config
														del inputs_dict["output_attentions"]
														__UpperCamelCase :   List[str]									=True
														__UpperCamelCase :   Tuple									=config.window_size**2
														__UpperCamelCase :   Optional[int]									=model_class(lowerCamelCase__       )
														__UpperCamelCase :   Any									=model(**self._prepare_for_class(lowerCamelCase__				,    lowerCamelCase__       )       )
														__UpperCamelCase :   Optional[int]									=outputs.attentions
														self.assertEqual(len(lowerCamelCase__       )				,    lowerCamelCase__       )

														self.assertListEqual(
														    list(attentions[0].shape[-3:]       )				,    [self.model_tester.num_heads[0], window_size_squared, window_size_squared]				,    )
														__UpperCamelCase :   Union[str, Any]									=len(lowerCamelCase__       )

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

														if hasattr(self.model_tester				,    'num_hidden_states_types'       ):
																			__UpperCamelCase :   Union[str, Any]									=self.model_tester.num_hidden_states_types
														else:
																			# also another +1 for reshaped_hidden_states
																			__UpperCamelCase :   Union[str, Any]									=2
														self.assertEqual(out_len + added_hidden_states				,    len(lowerCamelCase__       )       )

														__UpperCamelCase :   int									=outputs.attentions

														self.assertEqual(len(lowerCamelCase__       )				,    lowerCamelCase__       )

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


				def  __lowercase				(					self				,    lowerCamelCase__				,    lowerCamelCase__				,    lowerCamelCase__				,    lowerCamelCase__       ):




									"""simple docstring"""

									__UpperCamelCase :   List[Any]									=model_class(lowerCamelCase__       )
									__UpperCamelCase :   Optional[Any]									=model(**self._prepare_for_class(lowerCamelCase__				,    lowerCamelCase__       )       )
									__UpperCamelCase :   Optional[int]									=outputs.hidden_states

									__UpperCamelCase :   Dict									=getattr(
									    self.model_tester				,    'expected_num_hidden_layers'				,    len(self.model_tester.depths       ) + 1       )
									self.assertEqual(len(lowerCamelCase__       )				,    lowerCamelCase__       )

									# Swin has a different seq_length
									__UpperCamelCase :   Union[str, Any]									=to_atuple(config.patch_size       )

									__UpperCamelCase :   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]				,    )

									__UpperCamelCase :   List[Any]									=outputs.reshaped_hidden_states
									self.assertEqual(len(lowerCamelCase__       )				,    lowerCamelCase__       )

									__UpperCamelCase						,							__UpperCamelCase						,							__UpperCamelCase						,							__UpperCamelCase :   List[str]									=reshaped_hidden_states[0].shape

									__UpperCamelCase :   Dict									=tf.reshape(reshaped_hidden_states[0]				,    (batch_size, num_channels, height * width)       )
									__UpperCamelCase :   Any									=tf.transpose(lowerCamelCase__				,    (0, 2, 1)       )

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


				def  __lowercase				(					self       ):




									"""simple docstring"""

									__UpperCamelCase						,							__UpperCamelCase :   int									=self.model_tester.prepare_config_and_inputs_for_common()

									__UpperCamelCase :   Tuple									=to_atuple(self.model_tester.image_size       )

									for model_class in self.all_model_classes:
														__UpperCamelCase :   Dict									=True
														self.check_hidden_states_output(lowerCamelCase__				,    lowerCamelCase__				,    lowerCamelCase__				,    lowerCamelCase__       )

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

														self.check_hidden_states_output(lowerCamelCase__				,    lowerCamelCase__				,    lowerCamelCase__				,    lowerCamelCase__       )


				def  __lowercase				(					self       ):




									"""simple docstring"""

									__UpperCamelCase						,							__UpperCamelCase :   str									=self.model_tester.prepare_config_and_inputs_for_common()
									__UpperCamelCase :   Union[str, Any]									=3

									__UpperCamelCase :   int									=to_atuple(self.model_tester.image_size       )
									__UpperCamelCase :   Optional[Any]									=to_atuple(config.patch_size       )

									__UpperCamelCase :   Optional[int]									=image_size[0] + patch_size[0] - (image_size[0] % patch_size[0])
									__UpperCamelCase :   Dict									=image_size[1] + patch_size[1] - (image_size[1] % patch_size[1])

									for model_class in self.all_model_classes:
														__UpperCamelCase :   Any									=True
														self.check_hidden_states_output(lowerCamelCase__				,    lowerCamelCase__				,    lowerCamelCase__				,    (padded_height, padded_width)       )

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







				@slow
				def  __lowercase				(					self       ):




									"""simple docstring"""

									for model_name in TF_SWIN_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
														__UpperCamelCase :   Optional[int]									=TFSwinModel.from_pretrained(lowerCamelCase__       )
														self.assertIsNotNone(lowerCamelCase__       )




@require_vision
@require_tf
class 							__A	(     unittest.TestCase					):





				"""simple docstring"""







				@cached_property
				def  __lowercase				(					self       ):




									"""simple docstring"""

									return (
									    AutoImageProcessor.from_pretrained('microsoft/swin-tiny-patch4-window7-224'       )
									    if is_vision_available()
									    else None
									)







				@slow
				def  __lowercase				(					self       ):




									"""simple docstring"""

									__UpperCamelCase :   str									=TFSwinForImageClassification.from_pretrained('microsoft/swin-tiny-patch4-window7-224'       )
									__UpperCamelCase :   Optional[Any]									=self.default_image_processor

									__UpperCamelCase :   str									=Image.open('./tests/fixtures/tests_samples/COCO/000000039769.png'       )
									__UpperCamelCase :   List[str]									=image_processor(images=lowerCamelCase__				,    return_tensors='tf'       )

									# forward pass
									__UpperCamelCase :   Tuple									=model(lowerCamelCase__       )

									# verify the logits
									__UpperCamelCase :   Optional[int]									=tf.TensorShape((1, 1000)       )
									self.assertEqual(outputs.logits.shape				,    lowerCamelCase__       )
									__UpperCamelCase :   Optional[int]									=tf.constant([-0.0_948, -0.6_454, -0.0_921]       )
									self.assertTrue(np.allclose(outputs.logits[0, :3]				,    lowerCamelCase__				,    atol=1E-4       )       )

