


'''simple docstring'''



import unittest
from typing import Tuple

import torch

from diffusers.utils import floats_tensor, randn_tensor, torch_all_close, torch_device
from diffusers.utils.testing_utils import require_torch





@require_torch
class 							__UpperCamelCase    :




	@property
	def 				__UpperCAmelCase							(       self							):

						'''simple docstring'''





						return self.get_dummy_input()




	@property
	def 				__UpperCAmelCase							(       self							):

						'''simple docstring'''





						if self.block_type == "down":
											return (4, 32, 16, 16)
						elif self.block_type == "mid":
											return (4, 32, 32, 32)
						elif self.block_type == "up":
											return (4, 32, 64, 64)

						raise ValueError(f"""'{self.block_type}' is not a supported block_type. Set it to 'up', 'mid', or 'down'."""							)




	def 				__UpperCAmelCase							(       self						,    __a=True						,    __a=False						,    __a=False						,    __a=False						,    ):

						'''simple docstring'''





						__a      :	List[str]    =  4
						__a      :	Tuple    =  32
						__a      :	Optional[int]    =  (32, 32)

						__a      :	str    =  torch.manual_seed(0							)
						__a      :	Union[str, Any]    =  torch.device(__a							)
						__a      :	int    =  (batch_size, num_channels) + sizes
						__a      :	str    =  randn_tensor(__a						,    generator=__a						,    device=__a							)
						__a      :	int    =  {'hidden_states': hidden_states}

						if include_temb:
											__a      :	Optional[Any]    =  128
											__a      :	Dict    =  randn_tensor((batch_size, temb_channels)						,    generator=__a						,    device=__a							)

						if include_res_hidden_states_tuple:
											__a      :	Dict    =  torch.manual_seed(1							)
											__a      :	str    =  (randn_tensor(__a						,    generator=__a						,    device=__a							),)

						if include_encoder_hidden_states:
											__a      :	List[Any]    =  floats_tensor((batch_size, 32, 32)							).to(__a							)

						if include_skip_sample:
											__a      :	Dict    =  randn_tensor(((batch_size, 3) + sizes)						,    generator=__a						,    device=__a							)

						return dummy_input




	def 				__UpperCAmelCase							(       self							):

						'''simple docstring'''





						__a      :	List[Any]    =  {
						    'in_channels': 32,
						    'out_channels': 32,
						    'temb_channels': 128,
						}
						if self.block_type == "up":
											__a      :	Union[str, Any]    =  32

						if self.block_type == "mid":
											init_dict.pop('out_channels'							)

						__a      :	List[str]    =  self.dummy_input
						return init_dict, inputs_dict




	def 				__UpperCAmelCase							(       self						,    __a							):

						'''simple docstring'''





						__a   ,    __a      :	Union[str, Any]    =  self.prepare_init_args_and_inputs_for_common()
						__a      :	int    =  self.block_class(**__a							)
						unet_block.to(__a							)
						unet_block.eval()

						with torch.no_grad():
											__a      :	Tuple    =  unet_block(**__a							)

						if isinstance(__a						,    __a							):
											__a      :	Union[str, Any]    =  output[0]

						self.assertEqual(output.shape						,    self.output_shape							)

						__a      :	str    =  output[0, -1, -3:, -3:]
						__a      :	Optional[Any]    =  torch.tensor(__a							).to(__a							)
						assert torch_all_close(output_slice.flatten()						,    __a						,    atol=5E-3							)





	@unittest.skipIf(torch_device == 'mps'						,    'Training is not supported in mps'							)
	def 				__UpperCAmelCase							(       self							):

						'''simple docstring'''





						__a   ,    __a      :	Optional[int]    =  self.prepare_init_args_and_inputs_for_common()
						__a      :	Optional[Any]    =  self.block_class(**__a							)
						model.to(__a							)
						model.train()
						__a      :	Any    =  model(**__a							)

						if isinstance(__a						,    __a							):
											__a      :	Optional[int]    =  output[0]

						__a      :	Any    =  torch.device(__a							)
						__a      :	Union[str, Any]    =  randn_tensor(output.shape						,    device=__a							)
						__a      :	Union[str, Any]    =  torch.nn.functional.mse_loss(__a						,    __a							)
						loss.backward()







'''simple docstring'''



import sys

__lowercase     :						Union[str, Any]	=     (
    '73167176531330624919225119674426574742355349194934'
    '96983520312774506326239578318016984801869478851843'
    '85861560789112949495459501737958331952853208805511'
    '12540698747158523863050715693290963295227443043557'
    '66896648950445244523161731856403098711121722383113'
    '62229893423380308135336276614282806444486645238749'
    '30358907296290491560440772390713810515859307960866'
    '70172427121883998797908792274921901699720888093776'
    '65727333001053367881220235421809751254540594752243'
    '52584907711670556013604839586446706324415722155397'
    '53697817977846174064955149290862569321978468622482'
    '83972241375657056057490261407972968652414535100474'
    '82166370484403199890008895243450658541227588666881'
    '16427171479924442928230863465674813919123162824586'
    '17866458359124566529476545682848912883142607690042'
    '24219022671055626321111109370544217506941658960408'
    '07198403850962455444362981230987879927244284909188'
    '84580156166097919133875499200524063689912560717606'
    '05886116467109405077541002256983155200055935729725'
    '71636269561882670428252483600823257530420752963450'
)






def   lowerCamelCase							(_SCREAMING_SNAKE_CASE				:       str       ):
					__a      :	List[str]    =  1
					for digit in s:
										product *= int(_SCREAMING_SNAKE_CASE       )
					return product






def   lowerCamelCase							(_SCREAMING_SNAKE_CASE				:       str = N       ):
					__a      :	Optional[int]    =  -sys.maxsize - 1
					__a      :	Optional[Any]    =  n[:13]
					__a      :	int    =  13
					while cur_index < len(_SCREAMING_SNAKE_CASE       ) - 13:
										if int(n[cur_index]       ) >= int(substr[0]       ):
															__a      :	List[Any]    =  substr[1:] + n[cur_index]
															cur_index += 1
										else:
															__a      :	Dict    =  max(_SCREAMING_SNAKE_CASE						,				str_eval(_SCREAMING_SNAKE_CASE       )       )
															__a      :	Optional[Any]    =  n[cur_index : cur_index + 13]
															cur_index += 13
					return largest_product


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



