




import copy
import inspect
import unittest

from transformers import PretrainedConfig, SwiftFormerConfig
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_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 SwiftFormerForImageClassification, SwiftFormerModel
					from transformers.models.swiftformer.modeling_swiftformer import SWIFTFORMER_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
					from PIL import Image

					from transformers import ViTImageProcessor






class 					__magic_name__							:






				'''simple docstring'''





				def __init__( self	,				_a	,				_a=13	,				_a=3	,				_a=True	,				_a=True	,				_a=0.1	,				_a=0.1	,				_a=224	,				_a=1_000	,				_a=[3, 3, 6, 4]	,				_a=[48, 56, 112, 220]	,				):





							"""simple docstring"""
							lowerCamelCase       =      parent
							lowerCamelCase       =      batch_size
							lowerCamelCase       =      num_channels
							lowerCamelCase       =      is_training
							lowerCamelCase       =      use_labels
							lowerCamelCase       =      hidden_dropout_prob
							lowerCamelCase       =      attention_probs_dropout_prob
							lowerCamelCase       =      num_labels
							lowerCamelCase       =      image_size
							lowerCamelCase       =      layer_depths
							lowerCamelCase       =      embed_dims





				def      _lowerCAmelCase       ( self				):





							"""simple docstring"""
							lowerCamelCase       =      floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]				)

							lowerCamelCase       =      None
							if self.use_labels:
										lowerCamelCase       =      ids_tensor([self.batch_size]	,				self.num_labels				)

							lowerCamelCase       =      self.get_config()

							return config, pixel_values, labels





				def      _lowerCAmelCase       ( self				):





							"""simple docstring"""
							return SwiftFormerConfig(
							    depths=self.layer_depths	,				embed_dims=self.embed_dims	,				mlp_ratio=4	,				downsamples=[True, True, True, True]	,				hidden_act="""gelu"""	,				num_labels=self.num_labels	,				down_patch_size=3	,				down_stride=2	,				down_pad=1	,				drop_rate=0.0	,				drop_path_rate=0.0	,				use_layer_scale=_UpperCAmelCase	,				layer_scale_init_value=1e-5	,				)





				def      _lowerCAmelCase       ( self	,				_a	,				_a	,				_a				):





							"""simple docstring"""
							lowerCamelCase       =      SwiftFormerModel(config=_UpperCAmelCase				)
							model.to(_UpperCAmelCase				)
							model.eval()
							lowerCamelCase       =      model(_UpperCAmelCase				)
							self.parent.assertEqual(result.last_hidden_state.shape	,				(self.batch_size, self.embed_dims[-1], 7, 7)				)





				def      _lowerCAmelCase       ( self	,				_a	,				_a	,				_a				):





							"""simple docstring"""
							lowerCamelCase       =      self.num_labels
							lowerCamelCase       =      SwiftFormerForImageClassification(_UpperCAmelCase				)
							model.to(_UpperCAmelCase				)
							model.eval()
							lowerCamelCase       =      model(_UpperCAmelCase	,				labels=_UpperCAmelCase				)
							self.parent.assertEqual(result.logits.shape	,				(self.batch_size, self.num_labels)				)

							lowerCamelCase       =      SwiftFormerForImageClassification(_UpperCAmelCase				)
							model.to(_UpperCAmelCase				)
							model.eval()

							lowerCamelCase       =      floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]				)
							lowerCamelCase       =      model(_UpperCAmelCase				)
							self.parent.assertEqual(result.logits.shape	,				(self.batch_size, self.num_labels)				)





				def      _lowerCAmelCase       ( self				):





							"""simple docstring"""
							((lowerCamelCase)   ,     (lowerCamelCase)   ,     (lowerCamelCase))       =      self.prepare_config_and_inputs()
							lowerCamelCase       =      {"""pixel_values""": pixel_values}
							return config, inputs_dict






@require_torch
class 					__magic_name__							( UpperCAmelCase__		,      UpperCAmelCase__		,      unittest.TestCase       ):






				'''simple docstring'''
				__UpperCamelCase    						=		(SwiftFormerModel, SwiftFormerForImageClassification) if is_torch_available() else ()
				__UpperCamelCase    						=		(
				    {"feature-extraction": SwiftFormerModel, "image-classification": SwiftFormerForImageClassification}
				    if is_torch_available()
				    else {}
				)

				__UpperCamelCase    						=		False
				__UpperCamelCase    						=		False
				__UpperCamelCase    						=		False
				__UpperCamelCase    						=		False
				__UpperCamelCase    						=		False





				def      _lowerCAmelCase       ( self				):





							"""simple docstring"""
							lowerCamelCase       =      SwiftFormerModelTester(self				)
							lowerCamelCase       =      ConfigTester(
							    self	,				config_class=_UpperCAmelCase	,				has_text_modality=_UpperCAmelCase	,				hidden_size=37	,				num_attention_heads=12	,				num_hidden_layers=12	,				)





				def      _lowerCAmelCase       ( self				):





							"""simple docstring"""
							self.config_tester.run_common_tests()





				@unittest.skip(reason="""SwiftFormer does not use inputs_embeds"""				)
				def      _lowerCAmelCase       ( self				):





							"""simple docstring"""
							pass





				def      _lowerCAmelCase       ( self				):





							"""simple docstring"""
							lowerCamelCase   ,     lowerCamelCase       =      self.model_tester.prepare_config_and_inputs_for_common()

							for model_class in self.all_model_classes:
										lowerCamelCase       =      model_class(_UpperCAmelCase				)
										lowerCamelCase       =      model.get_output_embeddings()
										self.assertTrue(x is None or isinstance(_UpperCAmelCase	,				nn.Linear				)				)





				def      _lowerCAmelCase       ( self				):





							"""simple docstring"""
							lowerCamelCase   ,     lowerCamelCase       =      self.model_tester.prepare_config_and_inputs_for_common()

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

										lowerCamelCase       =      ["""pixel_values"""]
										self.assertListEqual(arg_names[:1]	,				_UpperCAmelCase				)





				def      _lowerCAmelCase       ( self				):





							"""simple docstring"""
							lowerCamelCase       =      self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_model(*_UpperCAmelCase				)





				def      _lowerCAmelCase       ( self				):





							"""simple docstring"""
							lowerCamelCase       =      self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_for_image_classification(*_UpperCAmelCase				)





				@slow
				def      _lowerCAmelCase       ( self				):





							"""simple docstring"""




							for model_name in SWIFTFORMER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
										lowerCamelCase       =      SwiftFormerModel.from_pretrained(_UpperCAmelCase				)
										self.assertIsNotNone(_UpperCAmelCase				)





				@unittest.skip(reason="""SwiftFormer does not output attentions"""				)
				def      _lowerCAmelCase       ( self				):





							"""simple docstring"""
							pass





				def      _lowerCAmelCase       ( self				):





							"""simple docstring"""




							def check_hidden_states_output(_a	,				_a	,				_a				):
										lowerCamelCase       =      model_class(_UpperCAmelCase				)
										model.to(_UpperCAmelCase				)
										model.eval()

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

										lowerCamelCase       =      outputs.hidden_states

										lowerCamelCase       =      8
										self.assertEqual(len(_UpperCAmelCase				)	,				_UpperCAmelCase				)  # TODO

										# SwiftFormer's feature maps are of shape (batch_size, embed_dims, height, width)
										# with the width and height being successively divided by 2, after every 2 blocks
										for i in range(len(_UpperCAmelCase				)				):
													self.assertEqual(
													    hidden_states[i].shape	,				torch.Size(
													        [
													            self.model_tester.batch_size,
													            self.model_tester.embed_dims[i // 2],
													            (self.model_tester.image_size // 4) // 2 ** (i // 2),
													            (self.model_tester.image_size // 4) // 2 ** (i // 2),
													        ]				)	,				)

							lowerCamelCase   ,     lowerCamelCase       =      self.model_tester.prepare_config_and_inputs_for_common()

							for model_class in self.all_model_classes:
										lowerCamelCase       =      True
										check_hidden_states_output(_UpperCAmelCase	,				_UpperCAmelCase	,				_UpperCAmelCase				)

										# check that output_hidden_states also work using config
										del inputs_dict["output_hidden_states"]
										lowerCamelCase       =      True

										check_hidden_states_output(_UpperCAmelCase	,				_UpperCAmelCase	,				_UpperCAmelCase				)





				def      _lowerCAmelCase       ( self				):





							"""simple docstring"""




							def _config_zero_init(_a				):
										lowerCamelCase       =      copy.deepcopy(_UpperCAmelCase				)
										for key in configs_no_init.__dict__.keys():
													if "_range" in key or "_std" in key or "initializer_factor" in key or "layer_scale" in key:
																setattr(_UpperCAmelCase	,				_UpperCAmelCase	,				1e-1_0				)
													if isinstance(getattr(_UpperCAmelCase	,				_UpperCAmelCase	,				_UpperCAmelCase				)	,				_UpperCAmelCase				):
																lowerCamelCase       =      _config_zero_init(getattr(_UpperCAmelCase	,				_UpperCAmelCase				)				)
																setattr(_UpperCAmelCase	,				_UpperCAmelCase	,				_UpperCAmelCase				)
										return configs_no_init

							lowerCamelCase   ,     lowerCamelCase       =      self.model_tester.prepare_config_and_inputs_for_common()

							lowerCamelCase       =      _config_zero_init(_UpperCAmelCase				)
							for model_class in self.all_model_classes:
										lowerCamelCase       =      model_class(config=_UpperCAmelCase				)
										for name, param in model.named_parameters():
													if param.requires_grad:
																self.assertIn(
																    ((param.data.mean() * 1e9) / 1e9).round().item()	,				[0.0, 1.0]	,				msg=f'Parameter {name} of model {model_class} seems not properly initialized'	,				)





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





							"""simple docstring"""
							pass




def 					a__				(       )		->      Optional[int]:
			lowerCamelCase       =      Image.open("""./tests/fixtures/tests_samples/COCO/000000039769.png"""       )
			return image






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






				'''simple docstring'''





				@cached_property
				def      _lowerCAmelCase       ( self				):





							"""simple docstring"""
							return ViTImageProcessor.from_pretrained("""MBZUAI/swiftformer-xs"""				) if is_vision_available() else None





				@slow
				def      _lowerCAmelCase       ( self				):





							"""simple docstring"""
							lowerCamelCase       =      SwiftFormerForImageClassification.from_pretrained("""MBZUAI/swiftformer-xs"""				).to(_UpperCAmelCase				)

							lowerCamelCase       =      self.default_image_processor
							lowerCamelCase       =      prepare_img()
							lowerCamelCase       =      image_processor(images=_UpperCAmelCase	,				return_tensors="""pt"""				).to(_UpperCAmelCase				)

							# forward pass
							with torch.no_grad():
										lowerCamelCase       =      model(**_UpperCAmelCase				)

							# verify the logits
							lowerCamelCase       =      torch.Size((1, 1_000)				)
							self.assertEqual(outputs.logits.shape	,				_UpperCAmelCase				)

							lowerCamelCase       =      torch.tensor([[-2.1_7_0_3e0_0, 2.1_1_0_7e0_0, -2.0_8_1_1e0_0]]				).to(_UpperCAmelCase				)
							self.assertTrue(torch.allclose(outputs.logits[0, :3]	,				_UpperCAmelCase	,				atol=1e-4				)				)









"""simple docstring"""




import random

import torch
from huggingface_hub import HfApi

from diffusers import UNetaDModel


lowerCAmelCase							:    List[str]  							=							HfApi()

lowerCAmelCase							:    Tuple  							=							{}
# fmt: off
lowerCAmelCase							:    List[str]  							=							torch.tensor([
    -0.7_5_1_5, -1.6_8_8_3, 0.2_4_2_0, 0.0_3_0_0, 0.6_3_4_7, 1.3_4_3_3, -1.1_7_4_3, -3.7_4_6_7,
    1.2_3_4_2, -2.2_4_8_5, 0.4_6_3_6, 0.8_0_7_6, -0.7_9_9_1, 0.3_9_6_9, 0.8_4_9_8, 0.9_1_8_9,
    -1.8_8_8_7, -3.3_5_2_2, 0.7_6_3_9, 0.2_0_4_0, 0.6_2_7_1, -2.7_1_4_8, -1.6_3_1_6, 3.0_8_3_9,
    0.3_1_8_6, 0.2_7_2_1, -0.9_7_5_9, -1.2_4_6_1, 2.6_2_5_7, 1.3_5_5_7
])
lowerCAmelCase							:    Dict  							=							torch.tensor([
    -2.3_6_3_9, -2.5_3_4_4, 0.0_0_5_4, -0.6_6_7_4, 1.5_9_9_0, 1.0_1_5_8, 0.3_1_2_4, -2.1_4_3_6,
    1.8_7_9_5, -2.5_4_2_9, -0.1_5_6_6, -0.3_9_7_3, 1.2_4_9_0, 2.6_4_4_7, 1.2_2_8_3, -0.5_2_0_8,
    -2.8_1_5_4, -3.5_1_1_9, 2.3_8_3_8, 1.2_0_3_3, 1.7_2_0_1, -2.1_2_5_6, -1.4_5_7_6, 2.7_9_4_8,
    2.4_2_0_4, -0.9_7_5_2, -1.2_5_4_6, 0.8_0_2_7, 3.2_7_5_8, 3.1_3_6_5
])
lowerCAmelCase							:    str  							=							torch.tensor([
    -0.6_5_3_1, -0.6_8_9_1, -0.3_1_7_2, -0.5_3_7_5, -0.9_1_4_0, -0.5_3_6_7, -0.1_1_7_5, -0.7_8_6_9,
    -0.3_8_0_8, -0.4_5_1_3, -0.2_0_9_8, -0.0_0_8_3, 0.3_1_8_3, 0.5_1_4_0, 0.2_2_4_7, -0.1_3_0_4,
    -0.1_3_0_2, -0.2_8_0_2, -0.2_0_8_4, -0.2_0_2_5, -0.4_9_6_7, -0.4_8_7_3, -0.0_8_6_1, 0.6_9_2_5,
    0.0_2_5_0, 0.1_2_9_0, -0.1_5_4_3, 0.6_3_1_6, 1.0_4_6_0, 1.4_9_4_3
])
lowerCAmelCase							:    List[Any]  							=							torch.tensor([
    0.0_9_1_1, 0.1_1_0_7, 0.0_1_8_2, 0.0_4_3_5, -0.0_8_0_5, -0.0_6_0_8, 0.0_3_8_1, 0.2_1_7_2,
    -0.0_2_8_0, 0.1_3_2_7, -0.0_2_9_9, -0.0_2_5_5, -0.0_0_5_0, -0.1_1_7_0, -0.1_0_4_6, 0.0_3_0_9,
    0.1_3_6_7, 0.1_7_2_8, -0.0_5_3_3, -0.0_7_4_8, -0.0_5_3_4, 0.1_6_2_4, 0.0_3_8_4, -0.1_8_0_5,
    -0.0_7_0_7, 0.0_6_4_2, 0.0_2_2_0, -0.0_1_3_4, -0.1_3_3_3, -0.1_5_0_5
])
lowerCAmelCase							:    int  							=							torch.tensor([
    0.1_3_2_1, 0.1_3_3_7, 0.0_4_4_0, 0.0_6_2_2, -0.0_5_9_1, -0.0_3_7_0, 0.0_5_0_3, 0.2_1_3_3,
    -0.0_1_7_7, 0.1_4_1_5, -0.0_1_1_6, -0.0_1_1_2, 0.0_0_4_4, -0.0_9_8_0, -0.0_7_8_9, 0.0_3_9_5,
    0.1_5_0_2, 0.1_7_8_5, -0.0_4_8_8, -0.0_5_1_4, -0.0_4_0_4, 0.1_5_3_9, 0.0_4_5_4, -0.1_5_5_9,
    -0.0_6_6_5, 0.0_6_5_9, 0.0_3_8_3, -0.0_0_0_5, -0.1_2_6_6, -0.1_3_8_6
])
lowerCAmelCase							:    int  							=							torch.tensor([
    0.1_1_5_4, 0.1_2_1_8, 0.0_3_0_7, 0.0_5_2_6, -0.0_7_1_1, -0.0_5_4_1, 0.0_3_6_6, 0.2_0_7_8,
    -0.0_2_6_7, 0.1_3_1_7, -0.0_2_2_6, -0.0_1_9_3, -0.0_0_1_4, -0.1_0_5_5, -0.0_9_0_2, 0.0_3_3_0,
    0.1_3_9_1, 0.1_7_0_9, -0.0_5_6_2, -0.0_6_9_3, -0.0_5_6_0, 0.1_4_8_2, 0.0_3_8_1, -0.1_6_8_3,
    -0.0_6_8_1, 0.0_6_6_1, 0.0_3_3_1, -0.0_0_4_6, -0.1_2_6_8, -0.1_4_3_1
])
lowerCAmelCase							:    Union[str, Any]  							=							torch.tensor([
    0.1_1_9_2, 0.1_2_4_0, 0.0_4_1_4, 0.0_6_0_6, -0.0_5_5_7, -0.0_4_1_2, 0.0_4_3_0, 0.2_0_4_2,
    -0.0_2_0_0, 0.1_3_8_5, -0.0_1_1_5, -0.0_1_3_2, 0.0_0_1_7, -0.0_9_6_5, -0.0_8_0_2, 0.0_3_9_8,
    0.1_4_3_3, 0.1_7_4_7, -0.0_4_5_8, -0.0_5_3_3, -0.0_4_0_7, 0.1_5_4_5, 0.0_4_1_9, -0.1_5_7_4,
    -0.0_6_4_5, 0.0_6_2_6, 0.0_3_4_1, -0.0_0_1_0, -0.1_1_9_9, -0.1_3_9_0
])
lowerCAmelCase							:    List[str]  							=							torch.tensor([
    0.1_0_7_5, 0.1_0_7_4, 0.0_2_0_5, 0.0_4_3_1, -0.0_7_7_4, -0.0_6_0_7, 0.0_2_9_8, 0.2_0_4_2,
    -0.0_3_2_0, 0.1_2_6_7, -0.0_2_8_1, -0.0_2_5_0, -0.0_0_6_4, -0.1_0_9_1, -0.0_9_4_6, 0.0_2_9_0,
    0.1_3_2_8, 0.1_6_5_0, -0.0_5_8_0, -0.0_7_3_8, -0.0_5_8_6, 0.1_4_4_0, 0.0_3_3_7, -0.1_7_4_6,
    -0.0_7_1_2, 0.0_6_0_5, 0.0_2_5_0, -0.0_0_9_9, -0.1_3_1_6, -0.1_4_7_3
])
lowerCAmelCase							:    Optional[int]  							=							torch.tensor([
    -1.4_5_7_2, -2.0_4_8_1, -0.0_4_1_4, -0.6_0_0_5, 1.4_1_3_6, 0.5_8_4_8, 0.4_0_2_8, -2.7_3_3_0,
    1.2_2_1_2, -2.1_2_2_8, 0.2_1_5_5, 0.4_0_3_9, 0.7_6_6_2, 2.0_5_3_5, 0.7_4_7_7, -0.3_2_4_3,
    -2.1_7_5_8, -2.7_6_4_8, 1.6_9_4_7, 0.7_0_2_6, 1.2_3_3_8, -1.6_0_7_8, -0.8_6_8_2, 2.2_8_1_0,
    1.8_5_7_4, -0.5_7_1_8, -0.5_5_8_6, -0.0_1_8_6, 2.3_4_1_5, 2.1_2_5_1])
lowerCAmelCase							:    Any  							=							torch.tensor([
    -1.3_6_9_0, -1.9_7_2_0, -0.4_0_9_0, -0.6_9_6_6, 1.4_6_6_0, 0.9_9_3_8, -0.1_3_8_5, -2.7_3_2_4,
    0.7_7_3_6, -1.8_9_1_7, 0.2_9_2_3, 0.4_2_9_3, 0.1_6_9_3, 1.4_1_1_2, 1.1_8_8_7, -0.3_1_8_1,
    -2.2_1_6_0, -2.6_3_8_1, 1.3_1_7_0, 0.8_1_6_3, 0.9_2_4_0, -1.6_5_4_4, -0.6_0_9_9, 2.5_2_5_9,
    1.6_4_3_0, -0.9_0_9_0, -0.9_3_9_2, -0.0_1_2_6, 2.4_2_6_8, 2.3_2_6_6
])
lowerCAmelCase							:    Union[str, Any]  							=							torch.tensor([
    -1.3_5_2_5, -1.9_6_2_8, -0.3_9_5_6, -0.6_8_6_0, 1.4_6_6_4, 1.0_0_1_4, -0.1_2_5_9, -2.7_2_1_2,
    0.7_7_7_2, -1.8_8_1_1, 0.2_9_9_6, 0.4_3_8_8, 0.1_7_0_4, 1.4_0_2_9, 1.1_7_0_1, -0.3_0_2_7,
    -2.2_0_5_3, -2.6_2_8_7, 1.3_3_5_0, 0.8_1_3_1, 0.9_2_7_4, -1.6_2_9_2, -0.6_0_9_8, 2.5_1_3_1,
    1.6_5_0_5, -0.8_9_5_8, -0.9_2_9_8, -0.0_1_5_1, 2.4_2_5_7, 2.3_3_5_5
])
lowerCAmelCase							:    str  							=							torch.tensor([
    -2.0_5_8_5, -2.7_8_9_7, -0.2_8_5_0, -0.8_9_4_0, 1.9_0_5_2, 0.5_7_0_2, 0.6_3_4_5, -3.8_9_5_9,
    1.5_9_3_2, -3.2_3_1_9, 0.1_9_7_4, 0.0_2_8_7, 1.7_5_6_6, 2.6_5_4_3, 0.8_3_8_7, -0.5_3_5_1,
    -3.2_7_3_6, -4.3_3_7_5, 2.9_0_2_9, 1.6_3_9_0, 1.4_6_4_0, -2.1_7_0_1, -1.9_0_1_3, 2.9_3_4_1,
    3.4_9_8_1, -0.6_2_5_5, -1.1_6_4_4, -0.1_5_9_1, 3.7_0_9_7, 3.2_0_6_6
])
lowerCAmelCase							:    List[str]  							=							torch.tensor([
    -2.3_1_3_9, -2.5_5_9_4, -0.0_1_9_7, -0.6_7_8_5, 1.7_0_0_1, 1.1_6_0_6, 0.3_0_7_5, -2.1_7_4_0,
    1.8_0_7_1, -2.5_6_3_0, -0.0_9_2_6, -0.3_8_1_1, 1.2_1_1_6, 2.6_2_4_6, 1.2_7_3_1, -0.5_3_9_8,
    -2.8_1_5_3, -3.6_1_4_0, 2.3_8_9_3, 1.3_2_6_2, 1.6_2_5_8, -2.1_8_5_6, -1.3_2_6_7, 2.8_3_9_5,
    2.3_7_7_9, -1.0_6_2_3, -1.2_4_6_8, 0.8_9_5_9, 3.3_3_6_7, 3.2_2_4_3
])
lowerCAmelCase							:    Optional[Any]  							=							torch.tensor([
    -2.0_6_2_8, -2.7_6_6_7, -0.2_0_8_9, -0.8_2_6_3, 2.0_5_3_9, 0.5_9_9_2, 0.6_4_9_5, -3.8_3_3_6,
    1.6_0_2_5, -3.2_8_1_7, 0.1_7_2_1, -0.0_6_3_3, 1.7_5_1_6, 2.7_0_3_9, 0.8_1_0_0, -0.5_9_0_8,
    -3.2_1_1_3, -4.4_3_4_3, 2.9_2_5_7, 1.3_6_3_2, 1.5_5_6_2, -2.1_4_8_9, -1.9_8_9_4, 3.0_5_6_0,
    3.3_3_9_6, -0.7_3_2_8, -1.0_4_1_7, 0.0_3_8_3, 3.7_0_9_3, 3.2_3_4_3
])
lowerCAmelCase							:    int  							=							torch.tensor([
    -1.4_5_7_4, -2.0_5_6_9, -0.0_4_7_3, -0.6_1_1_7, 1.4_0_1_8, 0.5_7_6_9, 0.4_1_2_9, -2.7_3_4_4,
    1.2_2_4_1, -2.1_3_9_7, 0.2_0_0_0, 0.3_9_3_7, 0.7_6_1_6, 2.0_4_5_3, 0.7_3_2_4, -0.3_3_9_1,
    -2.1_7_4_6, -2.7_7_4_4, 1.6_9_6_3, 0.6_9_2_1, 1.2_1_8_7, -1.6_1_7_2, -0.8_8_7_7, 2.2_4_3_9,
    1.8_4_7_1, -0.5_8_3_9, -0.5_6_0_5, -0.0_4_6_4, 2.3_2_5_0, 2.1_2_1_9
])
# fmt: on

lowerCAmelCase							:    Optional[int]  							=							api.list_models(filter="""diffusers""")
for mod in models:
					if "google" in mod.author or mod.modelId == "CompVis/ldm-celebahq-256":
										lowerCAmelCase							:    Dict  							=							"""/home/patrick/google_checkpoints/""" + mod.modelId.split("""/""")[-1]

										print(F"""Started running {mod.modelId}!!!""")

										if mod.modelId.startswith("""CompVis"""):
															lowerCAmelCase							:    str  							=							UNetaDModel.from_pretrained(local_checkpoint, subfolder="""unet""")
										else:
															lowerCAmelCase							:    Optional[Any]  							=							UNetaDModel.from_pretrained(local_checkpoint)

										torch.manual_seed(0)
										random.seed(0)

										lowerCAmelCase							:    Dict  							=							torch.randn(1, model.config.in_channels, model.config.sample_size, model.config.sample_size)
										lowerCAmelCase							:    List[Any]  							=							torch.tensor([10] * noise.shape[0])
										with torch.no_grad():
															lowerCAmelCase							:    Optional[int]  							=							model(noise, time_step).sample

										assert torch.allclose(
										    logits[0, 0, 0, :30], results["""_""".join("""_""".join(mod.modelId.split("""/""")).split("""-"""))], atol=1e-3
										)
										print(F"""{mod.modelId} has passed successfully!!!""")



