



"""simple docstring"""






from dataclasses import dataclass
from typing import Optional, Tuple, Union

import torch
import torch.nn as nn

from ..configuration_utils import ConfigMixin, register_to_config
from ..utils import BaseOutput, apply_forward_hook
from .modeling_utils import ModelMixin
from .vae import Decoder, DecoderOutput, Encoder, VectorQuantizer






@dataclass
class 	__snake_case	(     a_):
		snake_case__    :       torch.FloatTensor






class 	__snake_case	(     a_  ,					a_):




		@register_to_config
		def __init__(			self					:						Optional[int]						, __lowerCAmelCase					:						List[str] = 3						, __lowerCAmelCase					:						str = 3						, __lowerCAmelCase					:						Union[str, Any] = ("DownEncoderBlock2D",)						, __lowerCAmelCase					:						Union[str, Any] = ("UpDecoderBlock2D",)						, __lowerCAmelCase					:						Tuple = (6_4,)						, __lowerCAmelCase					:						Optional[Any] = 1						, __lowerCAmelCase					:						Union[str, Any] = "silu"						, __lowerCAmelCase					:						Optional[Any] = 3						, __lowerCAmelCase					:						Optional[Any] = 3_2						, __lowerCAmelCase					:						List[Any] = 2_5_6						, __lowerCAmelCase					:						Dict = 3_2						, __lowerCAmelCase					:						Union[str, Any] = None						, __lowerCAmelCase					:						int = 0.1_82_15						, __lowerCAmelCase					:						Dict = "group"						, ):






									"""simple docstring"""






									super().__init__()

									# pass init params to Encoder
									_lowerCamelCase						:    List[Any]         =			Encoder(
									    in_channels=lowercase_						, out_channels=lowercase_						, down_block_types=lowercase_						, block_out_channels=lowercase_						, layers_per_block=lowercase_						, act_fn=lowercase_						, norm_num_groups=lowercase_						, double_z=lowercase_						, )

									_lowerCamelCase						:    Optional[int]         =			vq_embed_dim if vq_embed_dim is not None else latent_channels

									_lowerCamelCase						:    Dict         =			nn.Convad(lowercase_						, lowercase_						, 1		)
									_lowerCamelCase						:    Optional[Any]         =			VectorQuantizer(lowercase_						, lowercase_						, beta=0.25						, remap=lowercase_						, sane_index_shape=lowercase_		)
									_lowerCamelCase						:    List[str]         =			nn.Convad(lowercase_						, lowercase_						, 1		)

									# pass init params to Decoder
									_lowerCamelCase						:    List[Any]         =			Decoder(
									    in_channels=lowercase_						, out_channels=lowercase_						, up_block_types=lowercase_						, block_out_channels=lowercase_						, layers_per_block=lowercase_						, act_fn=lowercase_						, norm_num_groups=lowercase_						, norm_type=lowercase_						, )




		@apply_forward_hook
		def 						SCREAMING_SNAKE_CASE    (			self					:						List[Any]						, __lowerCAmelCase					:						int						, __lowerCAmelCase					:						List[str] = True		):






									"""simple docstring"""






									_lowerCamelCase						:    List[Any]         =			self.encoder(lowercase_		)
									_lowerCamelCase						:    List[str]         =			self.quant_conv(lowercase_		)

									if not return_dict:
																return (h,)

									return VQEncoderOutput(latents=lowercase_		)




		@apply_forward_hook
		def 						SCREAMING_SNAKE_CASE    (			self					:						Union[str, Any]						, __lowerCAmelCase					:						Any						, __lowerCAmelCase					:						List[Any] = False						, __lowerCAmelCase					:						str = True		):






									"""simple docstring"""






									if not force_not_quantize:
																_lowerCamelCase      ,   _lowerCamelCase      ,   _lowerCamelCase						:    Dict         =			self.quantize(lowercase_		)
									else:
																_lowerCamelCase						:    Tuple         =			h
									_lowerCamelCase						:    int         =			self.post_quant_conv(lowercase_		)
									_lowerCamelCase						:    List[Any]         =			self.decoder(lowercase_						, quant if self.config.norm_type == '''spatial''' else None		)

									if not return_dict:
																return (dec,)

									return DecoderOutput(sample=lowercase_		)




		def 						SCREAMING_SNAKE_CASE    (			self					:						List[Any]						, __lowerCAmelCase					:						List[Any]						, __lowerCAmelCase					:						List[str] = True		):






									"""simple docstring"""






									_lowerCamelCase						:    Optional[int]         =			sample
									_lowerCamelCase						:    List[str]         =			self.encode(lowercase_		).latents
									_lowerCamelCase						:    List[str]         =			self.decode(lowercase_		).sample

									if not return_dict:
																return (dec,)

									return DecoderOutput(sample=lowercase_		)







"""simple docstring"""






from itertools import permutations






def 	snake_case_  (				A_ :		tuple						):


       '''simple docstring'''





       if num[3] % 2 != 0:
              return False

       if (num[2] + num[3] + num[4]) % 3 != 0:
              return False

       if num[5] % 5 != 0:
              return False

       _lowerCamelCase						:    Any         =			[7, 11, 13, 17]
       for i, test in enumerate(A_						):
              if (num[i + 4] * 1_00 + num[i + 5] * 10 + num[i + 6]) % test != 0:
                     return False
       return True






def 	snake_case_  (				A_ :		int = 10						):


       '''simple docstring'''





       return sum(
           int(''''''.join(map(A_,    A_						)						)						)
           for num in permutations(range(A_						)						)
           if is_substring_divisible(A_						)						)


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


