



"""simple docstring"""






import flax.linen as nn
import jax.numpy as jnp

from .attention_flax import FlaxTransformeraDModel
from .resnet_flax import FlaxDownsampleaD, FlaxResnetBlockaD, FlaxUpsampleaD






class 	__snake_case	(     nn.Module):
		snake_case__    :       str        =						4_2
		snake_case__    :       int        =						4_2
		snake_case__    :       Tuple        =						0.0
		snake_case__    :       List[str]        =						1
		snake_case__    :       List[Any]        =						1
		snake_case__    :       List[str]        =						True
		snake_case__    :       Any        =						False
		snake_case__    :       str        =						False
		snake_case__    :       List[Any]        =						False
		snake_case__    :       List[Any]        =						jnp.floataa




		def 						SCREAMING_SNAKE_CASE    (			self					:						Dict		):






									"""simple docstring"""






									_lowerCamelCase						:    Any         =			[]
									_lowerCamelCase						:    Any         =			[]

									for i in range(self.num_layers		):
																_lowerCamelCase						:    Optional[Any]         =			self.in_channels if i == 0 else self.out_channels

																_lowerCamelCase						:    Union[str, Any]         =			FlaxResnetBlockaD(
																    in_channels=_SCREAMING_SNAKE_CASE						, out_channels=self.out_channels						, dropout_prob=self.dropout						, dtype=self.dtype						, )
																resnets.append(_SCREAMING_SNAKE_CASE		)

																_lowerCamelCase						:    Tuple         =			FlaxTransformeraDModel(
																    in_channels=self.out_channels						, n_heads=self.num_attention_heads						, d_head=self.out_channels // self.num_attention_heads						, depth=1						, use_linear_projection=self.use_linear_projection						, only_cross_attention=self.only_cross_attention						, use_memory_efficient_attention=self.use_memory_efficient_attention						, dtype=self.dtype						, )
																attentions.append(_SCREAMING_SNAKE_CASE		)

									_lowerCamelCase						:    Union[str, Any]         =			resnets
									_lowerCamelCase						:    str         =			attentions

									if self.add_downsample:
																_lowerCamelCase						:    int         =			FlaxDownsampleaD(self.out_channels						, dtype=self.dtype		)




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






									"""simple docstring"""






									_lowerCamelCase						:    Dict         =			()

									for resnet, attn in zip(self.resnets						, self.attentions		):
																_lowerCamelCase						:    Union[str, Any]         =			resnet(_SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE						, deterministic=_SCREAMING_SNAKE_CASE		)
																_lowerCamelCase						:    Optional[int]         =			attn(_SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE						, deterministic=_SCREAMING_SNAKE_CASE		)
																output_states += (hidden_states,)

									if self.add_downsample:
																_lowerCamelCase						:    Union[str, Any]         =			self.downsamplers_a(_SCREAMING_SNAKE_CASE		)
																output_states += (hidden_states,)

									return hidden_states, output_states






class 	__snake_case	(     nn.Module):
		snake_case__    :       Optional[Any]        =						4_2
		snake_case__    :       List[str]        =						4_2
		snake_case__    :       List[Any]        =						0.0
		snake_case__    :       Tuple        =						1
		snake_case__    :       List[Any]        =						True
		snake_case__    :       Optional[Any]        =						jnp.floataa




		def 						SCREAMING_SNAKE_CASE    (			self					:						int		):






									"""simple docstring"""






									_lowerCamelCase						:    Optional[int]         =			[]

									for i in range(self.num_layers		):
																_lowerCamelCase						:    Union[str, Any]         =			self.in_channels if i == 0 else self.out_channels

																_lowerCamelCase						:    Union[str, Any]         =			FlaxResnetBlockaD(
																    in_channels=_SCREAMING_SNAKE_CASE						, out_channels=self.out_channels						, dropout_prob=self.dropout						, dtype=self.dtype						, )
																resnets.append(_SCREAMING_SNAKE_CASE		)
									_lowerCamelCase						:    Tuple         =			resnets

									if self.add_downsample:
																_lowerCamelCase						:    str         =			FlaxDownsampleaD(self.out_channels						, dtype=self.dtype		)




		def __call__(			self					:						Union[str, Any]						, __lowerCAmelCase					:						Dict						, __lowerCAmelCase					:						int						, __lowerCAmelCase					:						Union[str, Any]=True		):






									"""simple docstring"""






									_lowerCamelCase						:    Tuple         =			()

									for resnet in self.resnets:
																_lowerCamelCase						:    Optional[Any]         =			resnet(_SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE						, deterministic=_SCREAMING_SNAKE_CASE		)
																output_states += (hidden_states,)

									if self.add_downsample:
																_lowerCamelCase						:    int         =			self.downsamplers_a(_SCREAMING_SNAKE_CASE		)
																output_states += (hidden_states,)

									return hidden_states, output_states






class 	__snake_case	(     nn.Module):
		snake_case__    :       Optional[int]        =						4_2
		snake_case__    :       Dict        =						4_2
		snake_case__    :       List[Any]        =						4_2
		snake_case__    :       str        =						0.0
		snake_case__    :       Dict        =						1
		snake_case__    :       Dict        =						1
		snake_case__    :       Optional[Any]        =						True
		snake_case__    :       List[str]        =						False
		snake_case__    :       Union[str, Any]        =						False
		snake_case__    :       str        =						False
		snake_case__    :       Optional[int]        =						jnp.floataa




		def 						SCREAMING_SNAKE_CASE    (			self					:						List[str]		):






									"""simple docstring"""






									_lowerCamelCase						:    Optional[Any]         =			[]
									_lowerCamelCase						:    List[str]         =			[]

									for i in range(self.num_layers		):
																_lowerCamelCase						:    List[str]         =			self.in_channels if (i == self.num_layers - 1) else self.out_channels
																_lowerCamelCase						:    Any         =			self.prev_output_channel if i == 0 else self.out_channels

																_lowerCamelCase						:    str         =			FlaxResnetBlockaD(
																    in_channels=resnet_in_channels + res_skip_channels						, out_channels=self.out_channels						, dropout_prob=self.dropout						, dtype=self.dtype						, )
																resnets.append(_SCREAMING_SNAKE_CASE		)

																_lowerCamelCase						:    List[Any]         =			FlaxTransformeraDModel(
																    in_channels=self.out_channels						, n_heads=self.num_attention_heads						, d_head=self.out_channels // self.num_attention_heads						, depth=1						, use_linear_projection=self.use_linear_projection						, only_cross_attention=self.only_cross_attention						, use_memory_efficient_attention=self.use_memory_efficient_attention						, dtype=self.dtype						, )
																attentions.append(_SCREAMING_SNAKE_CASE		)

									_lowerCamelCase						:    Optional[Any]         =			resnets
									_lowerCamelCase						:    Tuple         =			attentions

									if self.add_upsample:
																_lowerCamelCase						:    List[Any]         =			FlaxUpsampleaD(self.out_channels						, dtype=self.dtype		)




		def __call__(			self					:						Any						, __lowerCAmelCase					:						int						, __lowerCAmelCase					:						Dict						, __lowerCAmelCase					:						Optional[int]						, __lowerCAmelCase					:						Dict						, __lowerCAmelCase					:						Optional[int]=True		):






									"""simple docstring"""






									for resnet, attn in zip(self.resnets						, self.attentions		):
																# pop res hidden states
																_lowerCamelCase						:    Tuple         =			res_hidden_states_tuple[-1]
																_lowerCamelCase						:    List[str]         =			res_hidden_states_tuple[:-1]
																_lowerCamelCase						:    Tuple         =			jnp.concatenate((hidden_states, res_hidden_states)						, axis=-1		)

																_lowerCamelCase						:    Dict         =			resnet(_SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE						, deterministic=_SCREAMING_SNAKE_CASE		)
																_lowerCamelCase						:    str         =			attn(_SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE						, deterministic=_SCREAMING_SNAKE_CASE		)

									if self.add_upsample:
																_lowerCamelCase						:    Optional[int]         =			self.upsamplers_a(_SCREAMING_SNAKE_CASE		)

									return hidden_states






class 	__snake_case	(     nn.Module):
		snake_case__    :       Any        =						4_2
		snake_case__    :       Dict        =						4_2
		snake_case__    :       Tuple        =						4_2
		snake_case__    :       Tuple        =						0.0
		snake_case__    :       Union[str, Any]        =						1
		snake_case__    :       Optional[Any]        =						True
		snake_case__    :       Dict        =						jnp.floataa




		def 						SCREAMING_SNAKE_CASE    (			self					:						int		):






									"""simple docstring"""






									_lowerCamelCase						:    Tuple         =			[]

									for i in range(self.num_layers		):
																_lowerCamelCase						:    Union[str, Any]         =			self.in_channels if (i == self.num_layers - 1) else self.out_channels
																_lowerCamelCase						:    Dict         =			self.prev_output_channel if i == 0 else self.out_channels

																_lowerCamelCase						:    int         =			FlaxResnetBlockaD(
																    in_channels=resnet_in_channels + res_skip_channels						, out_channels=self.out_channels						, dropout_prob=self.dropout						, dtype=self.dtype						, )
																resnets.append(_SCREAMING_SNAKE_CASE		)

									_lowerCamelCase						:    int         =			resnets

									if self.add_upsample:
																_lowerCamelCase						:    Dict         =			FlaxUpsampleaD(self.out_channels						, dtype=self.dtype		)




		def __call__(			self					:						Any						, __lowerCAmelCase					:						Optional[int]						, __lowerCAmelCase					:						Any						, __lowerCAmelCase					:						Union[str, Any]						, __lowerCAmelCase					:						Optional[int]=True		):






									"""simple docstring"""






									for resnet in self.resnets:
																# pop res hidden states
																_lowerCamelCase						:    Optional[Any]         =			res_hidden_states_tuple[-1]
																_lowerCamelCase						:    Union[str, Any]         =			res_hidden_states_tuple[:-1]
																_lowerCamelCase						:    List[str]         =			jnp.concatenate((hidden_states, res_hidden_states)						, axis=-1		)

																_lowerCamelCase						:    Any         =			resnet(_SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE						, deterministic=_SCREAMING_SNAKE_CASE		)

									if self.add_upsample:
																_lowerCamelCase						:    Optional[Any]         =			self.upsamplers_a(_SCREAMING_SNAKE_CASE		)

									return hidden_states






class 	__snake_case	(     nn.Module):
		snake_case__    :       Optional[int]        =						4_2
		snake_case__    :       Optional[Any]        =						0.0
		snake_case__    :       Union[str, Any]        =						1
		snake_case__    :       Optional[int]        =						1
		snake_case__    :       List[str]        =						False
		snake_case__    :       Any        =						False
		snake_case__    :       str        =						jnp.floataa




		def 						SCREAMING_SNAKE_CASE    (			self					:						Union[str, Any]		):






									"""simple docstring"""






									_lowerCamelCase						:    List[Any]         =			[
									    FlaxResnetBlockaD(
									        in_channels=self.in_channels						, out_channels=self.in_channels						, dropout_prob=self.dropout						, dtype=self.dtype						, )
									]

									_lowerCamelCase						:    Any         =			[]

									for _ in range(self.num_layers		):
																_lowerCamelCase						:    int         =			FlaxTransformeraDModel(
																    in_channels=self.in_channels						, n_heads=self.num_attention_heads						, d_head=self.in_channels // self.num_attention_heads						, depth=1						, use_linear_projection=self.use_linear_projection						, use_memory_efficient_attention=self.use_memory_efficient_attention						, dtype=self.dtype						, )
																attentions.append(_SCREAMING_SNAKE_CASE		)

																_lowerCamelCase						:    Dict         =			FlaxResnetBlockaD(
																    in_channels=self.in_channels						, out_channels=self.in_channels						, dropout_prob=self.dropout						, dtype=self.dtype						, )
																resnets.append(_SCREAMING_SNAKE_CASE		)

									_lowerCamelCase						:    Optional[Any]         =			resnets
									_lowerCamelCase						:    Union[str, Any]         =			attentions




		def __call__(			self					:						int						, __lowerCAmelCase					:						List[Any]						, __lowerCAmelCase					:						List[Any]						, __lowerCAmelCase					:						Optional[Any]						, __lowerCAmelCase					:						List[str]=True		):






									"""simple docstring"""






									_lowerCamelCase						:    List[str]         =			self.resnets[0](_SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE		)
									for attn, resnet in zip(self.attentions						, self.resnets[1:]		):
																_lowerCamelCase						:    Optional[Any]         =			attn(_SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE						, deterministic=_SCREAMING_SNAKE_CASE		)
																_lowerCamelCase						:    Optional[int]         =			resnet(_SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE						, deterministic=_SCREAMING_SNAKE_CASE		)

									return hidden_states







"""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() = }""")


