






'''simple docstring'''



import collections
import inspect
import unittest

from transformers import FocalNetConfig
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 (
          FocalNetBackbone,
          FocalNetForImageClassification,
          FocalNetForMaskedImageModeling,
          FocalNetModel,
      )
      from transformers.models.focalnet.modeling_focalnet import FOCALNET_PRETRAINED_MODEL_ARCHIVE_LIST

if is_vision_available():
      from PIL import Image

      from transformers import AutoImageProcessor
class UpperCAmelCase_       :




      """simple docstring"""




      def __init__(			self      :		Any  ,   UpperCAmelCase      :		Optional[Any]  ,   UpperCAmelCase      :		str=13  ,   UpperCAmelCase      :		Any=32  ,   UpperCAmelCase      :		List[str]=2  ,   UpperCAmelCase      :		Any=3  ,   UpperCAmelCase      :		Dict=16  ,   UpperCAmelCase      :		Optional[int]=[32, 64, 128]  ,   UpperCAmelCase      :		Any=[1, 2, 1]  ,   UpperCAmelCase      :		Union[str, Any]=[2, 2, 4]  ,   UpperCAmelCase      :		str=2  ,   UpperCAmelCase      :		Optional[Any]=2.0  ,   UpperCAmelCase      :		List[Any]=True  ,   UpperCAmelCase      :		Any=0.0  ,   UpperCAmelCase      :		List[Any]=0.0  ,   UpperCAmelCase      :		int=0.1  ,   UpperCAmelCase      :		Tuple="gelu"  ,   UpperCAmelCase      :		List[Any]=False  ,   UpperCAmelCase      :		str=True  ,   UpperCAmelCase      :		List[str]=0.0_2  ,   UpperCAmelCase      :		Optional[int]=1e-5  ,   UpperCAmelCase      :		Union[str, Any]=True  ,   UpperCAmelCase      :		List[Any]=None  ,   UpperCAmelCase      :		Tuple=True  ,   UpperCAmelCase      :		List[str]=10  ,   UpperCAmelCase      :		Any=8  ,   UpperCAmelCase      :		Optional[Any]=["stage1", "stage2"]  ,   UpperCAmelCase      :		Optional[Any]=[1, 2]  ,   )	->	int:


       '''simple docstring'''

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






      def 					A__   (			self      :		List[Any]		)	->	Dict:


       '''simple docstring'''

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

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

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

       return config, pixel_values, labels






      def 					A__   (			self      :		str		)	->	List[str]:


       '''simple docstring'''

       return FocalNetConfig(
           image_size=self.image_size  ,   patch_size=self.patch_size  ,   num_channels=self.num_channels  ,   embed_dim=self.embed_dim  ,   hidden_sizes=self.hidden_sizes  ,   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 					A__   (			self      :		Tuple  ,   UpperCAmelCase      :		str  ,   UpperCAmelCase      :		Any  ,   UpperCAmelCase      :		Tuple		)	->	Any:


       '''simple docstring'''

       lowercase       : Tuple						=FocalNetModel(config=UpperCAmelCase		)
       model.to(UpperCAmelCase		)
       model.eval()
       lowercase       : Optional[Any]						=model(UpperCAmelCase		)

       lowercase       : Dict						=((config.image_size // config.patch_size) ** 2) // (4 ** (len(config.depths		) - 1))
       lowercase       : Optional[int]						=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 					A__   (			self      :		Any  ,   UpperCAmelCase      :		Any  ,   UpperCAmelCase      :		Optional[Any]  ,   UpperCAmelCase      :		int		)	->	str:


       '''simple docstring'''

       lowercase       : str						=FocalNetBackbone(config=UpperCAmelCase		)
       model.to(UpperCAmelCase		)
       model.eval()
       lowercase       : List[Any]						=model(UpperCAmelCase		)

       # verify feature maps
       self.parent.assertEqual(len(result.feature_maps		)  ,   len(config.out_features		)		)
       self.parent.assertListEqual(list(result.feature_maps[0].shape		)  ,   [self.batch_size, self.image_size, 8, 8]		)

       # verify channels
       self.parent.assertEqual(len(model.channels		)  ,   len(config.out_features		)		)
       self.parent.assertListEqual(model.channels  ,   config.hidden_sizes[:-1]		)

       # verify backbone works with out_features=None
       lowercase       : List[str]						=None
       lowercase       : Dict						=FocalNetBackbone(config=UpperCAmelCase		)
       model.to(UpperCAmelCase		)
       model.eval()
       lowercase       : Any						=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, self.image_size * 2, 4, 4]		)

       # verify channels
       self.parent.assertEqual(len(model.channels		)  ,   1		)
       self.parent.assertListEqual(model.channels  ,   [config.hidden_sizes[-1]]		)






      def 					A__   (			self      :		Tuple  ,   UpperCAmelCase      :		Tuple  ,   UpperCAmelCase      :		Any  ,   UpperCAmelCase      :		List[Any]		)	->	Optional[Any]:


       '''simple docstring'''

       lowercase       : List[Any]						=FocalNetForMaskedImageModeling(config=UpperCAmelCase		)
       model.to(UpperCAmelCase		)
       model.eval()
       lowercase       : List[Any]						=model(UpperCAmelCase		)
       self.parent.assertEqual(
           result.reconstruction.shape  ,   (self.batch_size, self.num_channels, self.image_size, self.image_size)		)

       # test greyscale images
       lowercase       : Optional[Any]						=1
       lowercase       : int						=FocalNetForMaskedImageModeling(UpperCAmelCase		)
       model.to(UpperCAmelCase		)
       model.eval()

       lowercase       : Optional[int]						=floats_tensor([self.batch_size, 1, self.image_size, self.image_size]		)
       lowercase       : Tuple						=model(UpperCAmelCase		)
       self.parent.assertEqual(result.reconstruction.shape  ,   (self.batch_size, 1, self.image_size, self.image_size)		)






      def 					A__   (			self      :		List[str]  ,   UpperCAmelCase      :		Optional[Any]  ,   UpperCAmelCase      :		Tuple  ,   UpperCAmelCase      :		int		)	->	List[str]:


       '''simple docstring'''

       lowercase       : Any						=self.type_sequence_label_size
       lowercase       : Optional[int]						=FocalNetForImageClassification(UpperCAmelCase		)
       model.to(UpperCAmelCase		)
       model.eval()
       lowercase       : Union[str, Any]						=model(UpperCAmelCase  ,   labels=UpperCAmelCase		)
       self.parent.assertEqual(result.logits.shape  ,   (self.batch_size, self.type_sequence_label_size)		)

       # test greyscale images
       lowercase       : List[Any]						=1
       lowercase       : Optional[Any]						=FocalNetForImageClassification(UpperCAmelCase		)
       model.to(UpperCAmelCase		)
       model.eval()

       lowercase       : Dict						=floats_tensor([self.batch_size, 1, self.image_size, self.image_size]		)
       lowercase       : Optional[int]						=model(UpperCAmelCase		)
       self.parent.assertEqual(result.logits.shape  ,   (self.batch_size, self.type_sequence_label_size)		)






      def 					A__   (			self      :		List[Any]		)	->	Optional[Any]:


       '''simple docstring'''

       lowercase       : List[str]						=self.prepare_config_and_inputs()

       lowercase	,		lowercase	,		lowercase       : Optional[int]						=config_and_inputs
       lowercase       : List[str]						={'''pixel_values''': pixel_values}
       return config, inputs_dict





@require_torch
class UpperCAmelCase_       (     __A					,							__A					,							unittest.TestCase					):




      """simple docstring"""




      UpperCamelCase_             =      (
          (
              FocalNetModel,
              FocalNetForImageClassification,
              FocalNetForMaskedImageModeling,
              FocalNetBackbone,
          )
          if is_torch_available()
          else ()
      )
      UpperCamelCase_             =      (
          {'''feature-extraction''': FocalNetModel, '''image-classification''': FocalNetForImageClassification}
          if is_torch_available()
          else {}
      )
      UpperCamelCase_             =      False

      UpperCamelCase_             =      False
      UpperCamelCase_             =      False
      UpperCamelCase_             =      False
      UpperCamelCase_             =      False






      def 					A__   (			self      :		Any		)	->	List[Any]:


       '''simple docstring'''

       lowercase       : Any						=FocalNetModelTester(self		)
       lowercase       : Optional[int]						=ConfigTester(self  ,   config_class=UpperCAmelCase  ,   embed_dim=37  ,   has_text_modality=UpperCAmelCase		)






      def 					A__   (			self      :		str		)	->	Any:


       '''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 					A__   (			self      :		Union[str, Any]		)	->	List[Any]:


       '''simple docstring'''

       return






      def 					A__   (			self      :		Tuple		)	->	Dict:


       '''simple docstring'''

       lowercase       : List[str]						=self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_model(*UpperCAmelCase		)






      def 					A__   (			self      :		Optional[int]		)	->	Tuple:


       '''simple docstring'''

       lowercase       : Optional[int]						=self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_backbone(*UpperCAmelCase		)






      def 					A__   (			self      :		List[str]		)	->	Union[str, Any]:


       '''simple docstring'''

       lowercase       : str						=self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_masked_image_modeling(*UpperCAmelCase		)






      def 					A__   (			self      :		Dict		)	->	Optional[Any]:


       '''simple docstring'''

       lowercase       : int						=self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_image_classification(*UpperCAmelCase		)






      @unittest.skip(reason='''FocalNet does not use inputs_embeds'''		)
      def 					A__   (			self      :		Optional[int]		)	->	str:


       '''simple docstring'''

       pass






      @unittest.skip(reason='''FocalNet does not use feedforward chunking'''		)
      def 					A__   (			self      :		Optional[Any]		)	->	Optional[Any]:


       '''simple docstring'''

       pass






      def 					A__   (			self      :		int		)	->	Dict:


       '''simple docstring'''

       lowercase	,		lowercase       : List[str]						=self.model_tester.prepare_config_and_inputs_for_common()

       for model_class in self.all_model_classes[:-1]:
        lowercase       : Tuple						=model_class(UpperCAmelCase		)
        self.assertIsInstance(model.get_input_embeddings()  ,   (nn.Module)		)
        lowercase       : Dict						=model.get_output_embeddings()
        self.assertTrue(x is None or isinstance(UpperCAmelCase  ,   nn.Linear		)		)






      def 					A__   (			self      :		int		)	->	Optional[Any]:


       '''simple docstring'''

       lowercase	,		lowercase       : List[str]						=self.model_tester.prepare_config_and_inputs_for_common()

       for model_class in self.all_model_classes[:-1]:
        lowercase       : str						=model_class(UpperCAmelCase		)
        lowercase       : Union[str, Any]						=inspect.signature(model.forward		)
        # signature.parameters is an OrderedDict => so arg_names order is deterministic
        lowercase       : Optional[Any]						=[*signature.parameters.keys()]

        lowercase       : List[Any]						=['''pixel_values''']
        self.assertListEqual(arg_names[:1]  ,   UpperCAmelCase		)






      def 					A__   (			self      :		int  ,   UpperCAmelCase      :		Tuple  ,   UpperCAmelCase      :		Union[str, Any]  ,   UpperCAmelCase      :		List[str]  ,   UpperCAmelCase      :		Union[str, Any]		)	->	Optional[int]:


       '''simple docstring'''

       lowercase       : int						=model_class(UpperCAmelCase		)
       model.to(UpperCAmelCase		)
       model.eval()

       with torch.no_grad():
        lowercase       : Any						=model(**self._prepare_for_class(UpperCAmelCase  ,   UpperCAmelCase		)		)

       lowercase       : str						=outputs.hidden_states

       lowercase       : Tuple						=getattr(
           self.model_tester  ,   '''expected_num_hidden_layers'''  ,   len(self.model_tester.depths		) + 1		)
       self.assertEqual(len(UpperCAmelCase		)  ,   UpperCAmelCase		)

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

       lowercase       : int						=(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]  ,   )

       lowercase       : List[Any]						=outputs.reshaped_hidden_states
       self.assertEqual(len(UpperCAmelCase		)  ,   UpperCAmelCase		)

       lowercase	,		lowercase	,		lowercase	,		lowercase       : Any						=reshaped_hidden_states[0].shape
       lowercase       : Union[str, 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 					A__   (			self      :		List[Any]		)	->	int:


       '''simple docstring'''

       lowercase	,		lowercase       : Any						=self.model_tester.prepare_config_and_inputs_for_common()

       lowercase       : 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[:-1]:
        lowercase       : Optional[int]						=True
        self.check_hidden_states_output(UpperCAmelCase  ,   UpperCAmelCase  ,   UpperCAmelCase  ,   UpperCAmelCase		)

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

        self.check_hidden_states_output(UpperCAmelCase  ,   UpperCAmelCase  ,   UpperCAmelCase  ,   UpperCAmelCase		)






      def 					A__   (			self      :		Union[str, Any]		)	->	Optional[Any]:


       '''simple docstring'''

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

       lowercase       : Any						=(
           self.model_tester.image_size
           if isinstance(self.model_tester.image_size  ,   collections.abc.Iterable		)
           else (self.model_tester.image_size, self.model_tester.image_size)
       )
       lowercase       : List[str]						=(
           config.patch_size
           if isinstance(config.patch_size  ,   collections.abc.Iterable		)
           else (config.patch_size, config.patch_size)
       )

       lowercase       : Optional[int]						=image_size[0] + patch_size[0] - (image_size[0] % patch_size[0])
       lowercase       : List[str]						=image_size[1] + patch_size[1] - (image_size[1] % patch_size[1])

       for model_class in self.all_model_classes[:-1]:
        lowercase       : List[Any]						=True
        self.check_hidden_states_output(UpperCAmelCase  ,   UpperCAmelCase  ,   UpperCAmelCase  ,   (padded_height, padded_width)		)

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






      @slow
      def 					A__   (			self      :		str		)	->	Optional[int]:


       '''simple docstring'''

       for model_name in FOCALNET_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
        lowercase       : str						=FocalNetModel.from_pretrained(UpperCAmelCase		)
        self.assertIsNotNone(UpperCAmelCase		)






      def 					A__   (			self      :		Any		)	->	Tuple:


       '''simple docstring'''

       lowercase	,		lowercase       : Any						=self.model_tester.prepare_config_and_inputs_for_common()

       lowercase       : List[Any]						=_config_zero_init(UpperCAmelCase		)
       for model_class in self.all_model_classes:
        lowercase       : Optional[Any]						=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 UpperCAmelCase_       (     unittest.TestCase					):




      """simple docstring"""




      @cached_property
      def 					A__   (			self      :		Any		)	->	List[Any]:


       '''simple docstring'''

       return AutoImageProcessor.from_pretrained('''microsoft/focalnet-tiny'''		) if is_vision_available() else None






      @slow
      def 					A__   (			self      :		List[Any]		)	->	Any:


       '''simple docstring'''

       lowercase       : Any						=FocalNetForImageClassification.from_pretrained('''microsoft/focalnet-tiny'''		).to(UpperCAmelCase		)
       lowercase       : Any						=self.default_image_processor

       lowercase       : Tuple						=Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png'''		)
       lowercase       : Any						=image_processor(images=UpperCAmelCase  ,   return_tensors='''pt'''		).to(UpperCAmelCase		)

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

       # verify the logits
       lowercase       : int						=torch.Size((1, 1000)		)
       self.assertEqual(outputs.logits.shape  ,   UpperCAmelCase		)
       lowercase       : Any						=torch.tensor([0.2_1_6_6, -0.4_3_6_8, 0.2_1_9_1]		).to(UpperCAmelCase		)
       self.assertTrue(torch.allclose(outputs.logits[0, :3]  ,   UpperCAmelCase  ,   atol=1e-4		)		)
       self.assertTrue(outputs.logits.argmax(dim=-1		).item()  ,   281		)





@require_torch
class UpperCAmelCase_       (     __A					,							unittest.TestCase					):




      """simple docstring"""




      UpperCamelCase_             =      (FocalNetBackbone,) if is_torch_available() else ()
      UpperCamelCase_             =      FocalNetConfig

      UpperCamelCase_             =      False






      def 					A__   (			self      :		str		)	->	Union[str, Any]:


       '''simple docstring'''

       lowercase       : Optional[Any]						=FocalNetModelTester(self		)







import unittest

import numpy as np
import torch

from diffusers import PNDMPipeline, PNDMScheduler, UNetaDModel
from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device


enable_full_determinism()







class 						_snake_case    ( unittest.TestCase				):




 @property
 def 			SCREAMING_SNAKE_CASE__							(						self       ):
       torch.manual_seed(0       )
       a		:List[Any]									=			UNetaDModel(
           block_out_channels=(32, 64)   ,    layers_per_block=2   ,    sample_size=32   ,    in_channels=3   ,    out_channels=3   ,    down_block_types=('''DownBlock2D''', '''AttnDownBlock2D''')   ,    up_block_types=('''AttnUpBlock2D''', '''UpBlock2D''')   ,    )
       return model




 def 			SCREAMING_SNAKE_CASE__							(						self       ):
       a		:Union[str, Any]									=			self.dummy_uncond_unet
       a		:Any									=			PNDMScheduler()

       a		:Any									=			PNDMPipeline(unet=_lowerCamelCase   ,    scheduler=_lowerCamelCase       )
       pndm.to(_lowerCamelCase       )
       pndm.set_progress_bar_config(disable=_lowerCamelCase       )

       a		:Any									=			torch.manual_seed(0       )
       a		:List[str]									=			pndm(generator=_lowerCamelCase   ,    num_inference_steps=20   ,    output_type='''numpy'''       ).images

       a		:int									=			torch.manual_seed(0       )
       a		:str									=			pndm(generator=_lowerCamelCase   ,    num_inference_steps=20   ,    output_type='''numpy'''   ,    return_dict=_lowerCamelCase       )[0]

       a		:int									=			image[0, -3:, -3:, -1]
       a		:List[str]									=			image_from_tuple[0, -3:, -3:, -1]

       assert image.shape == (1, 32, 32, 3)
       a		:str									=			np.array([1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0]       )

       assert np.abs(image_slice.flatten() - expected_slice       ).max() < 1e-2
       assert np.abs(image_from_tuple_slice.flatten() - expected_slice       ).max() < 1e-2







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




 def 			SCREAMING_SNAKE_CASE__							(						self       ):
       a		:int									=			'''google/ddpm-cifar10-32'''

       a		:str									=			UNetaDModel.from_pretrained(_lowerCamelCase       )
       a		:Optional[Any]									=			PNDMScheduler()

       a		:Union[str, Any]									=			PNDMPipeline(unet=_lowerCamelCase   ,    scheduler=_lowerCamelCase       )
       pndm.to(_lowerCamelCase       )
       pndm.set_progress_bar_config(disable=_lowerCamelCase       )
       a		:Dict									=			torch.manual_seed(0       )
       a		:List[str]									=			pndm(generator=_lowerCamelCase   ,    output_type='''numpy'''       ).images

       a		:List[Any]									=			image[0, -3:, -3:, -1]

       assert image.shape == (1, 32, 32, 3)
       a		:int									=			np.array([0.1564, 0.1_4645, 0.1406, 0.1_4715, 0.1_2425, 0.1_4045, 0.1_3115, 0.1_2175, 0.125]       )

       assert np.abs(image_slice.flatten() - expected_slice       ).max() < 1e-2





