






import unittest

import torch

from diffusers import VQModel
from diffusers.utils import floats_tensor, torch_device
from diffusers.utils.testing_utils import enable_full_determinism

from .test_modeling_common import ModelTesterMixin, UNetTesterMixin


enable_full_determinism()


class 			SCREAMING_SNAKE_CASE      (      __lowerCAmelCase   ,		__lowerCAmelCase   ,		unittest.TestCase       ):
     '''simple docstring'''


     UpperCamelCase_				:		List[Any]								=						VQModel
     UpperCamelCase_				:		str								=						'''sample'''


     @property
     def 					_A							(					self							:						Union[str, Any]       ,			UpperCAmelCase_							:						str=(32, 32)   ):
       SCREAMING_SNAKE_CASE							:   Union[str, Any]						    =     4
       SCREAMING_SNAKE_CASE							:   Optional[int]						    =     3

       SCREAMING_SNAKE_CASE							:   Dict						    =     floats_tensor((batch_size, num_channels) + sizes   ).to(__SCREAMING_SNAKE_CASE   )

       return {"sample": image}


     @property
     def 					_A							(					self							:						Any   ):
       return (3, 32, 32)


     @property
     def 					_A							(					self							:						List[str]   ):
       return (3, 32, 32)


     def 					_A							(					self							:						List[Any]   ):
       SCREAMING_SNAKE_CASE							:   Any						    =     {
           "block_out_channels": [32, 64],
           "in_channels": 3,
           "out_channels": 3,
           "down_block_types": ["DownEncoderBlock2D", "DownEncoderBlock2D"],
           "up_block_types": ["UpDecoderBlock2D", "UpDecoderBlock2D"],
           "latent_channels": 3,
       }
       SCREAMING_SNAKE_CASE							:   Optional[int]						    =     self.dummy_input
       return init_dict, inputs_dict


     def 					_A							(					self							:						Tuple   ):
       pass


     def 					_A							(					self							:						List[Any]   ):
       pass


     def 					_A							(					self							:						Optional[Any]   ):
       SCREAMING_SNAKE_CASE    ,	SCREAMING_SNAKE_CASE							:   Dict						    =     VQModel.from_pretrained("fusing/vqgan-dummy"       ,			output_loading_info=__SCREAMING_SNAKE_CASE   )
       self.assertIsNotNone(__SCREAMING_SNAKE_CASE   )
       self.assertEqual(len(loading_info["missing_keys"]   )       ,			0   )

       model.to(__SCREAMING_SNAKE_CASE   )
       SCREAMING_SNAKE_CASE							:   Union[str, Any]						    =     model(**self.dummy_input   )

       assert image is not None, "Make sure output is not None"






     def 					_A							(					self							:						Tuple   ):
       SCREAMING_SNAKE_CASE							:   str						    =     VQModel.from_pretrained("fusing/vqgan-dummy"   )
       model.to(__SCREAMING_SNAKE_CASE   ).eval()

       torch.manual_seed(0   )
       if torch.cuda.is_available():
         torch.cuda.manual_seed_all(0   )

       SCREAMING_SNAKE_CASE							:   str						    =     torch.randn(1       ,			model.config.in_channels       ,			model.config.sample_size       ,			model.config.sample_size   )
       SCREAMING_SNAKE_CASE							:   str						    =     image.to(__SCREAMING_SNAKE_CASE   )
       with torch.no_grad():
         SCREAMING_SNAKE_CASE							:   Dict						    =     model(__SCREAMING_SNAKE_CASE   ).sample

       SCREAMING_SNAKE_CASE							:   List[Any]						    =     output[0, -1, -3:, -3:].flatten().cpu()
       # fmt: off
       SCREAMING_SNAKE_CASE							:   Union[str, Any]						    =     torch.tensor([-0.0_153, -0.4_044, -0.1_880, -0.5_161, -0.2_418, -0.4_072, -0.1_612, -0.0_633, -0.0_143]   )
       # fmt: on
       self.assertTrue(torch.allclose(__SCREAMING_SNAKE_CASE       ,			__SCREAMING_SNAKE_CASE       ,			atol=1E-3   )   )












'''simple docstring'''



def       _UpperCamelCase			(_lowerCamelCase				:  int						)-> int:




     '''simple docstring'''





     __snake_case            =	[[0 for _ in range(_lowerCamelCase						)] for _ in range(m + 1						)]
     for i in range(m + 1						):
          __snake_case            =	1

     for n in range(m + 1						):
          for k in range(1 ,						_lowerCamelCase						):
               memo[n][k] += memo[n][k - 1]
               if n - k > 0:
                    memo[n][k] += memo[n - k - 1][k]

     return memo[m][m - 1]


if __name__ == "__main__":
     import sys

     if len(sys.argv) == 1:
          try:
               UpperCAmelCase_							:	List[str]	     =		int(input('''Enter a number: ''').strip())
               print(partition(n))
          except ValueError:
               print('''Please enter a number.''')
     else:
          try:
               UpperCAmelCase_							:	Union[str, Any]	     =		int(sys.argv[1])
               print(partition(n))
          except ValueError:
               print('''Please pass a number.''')






