




"""simple docstring"""







import requests





def 							lowercase					(snake_case__   : int      ,       snake_case__   : str )     ->  List[Any]:


				'''simple docstring'''






				lowerCAmelCase  =				{"""Content-Type""": """application/json"""}
				lowerCAmelCase  =				requests.post(UpperCAmelCase__      ,       json={"""text""": message_body}      ,       headers=UpperCAmelCase__ )
				if response.status_code != 200:
								lowerCAmelCase  =				(
								    """Request to slack returned an error """
								    f'''{response.status_code}, the response is:\n{response.text}'''
								)
								raise ValueError(UpperCAmelCase__ )


if __name__ == "__main__":
		# Set the slack url to the one provided by Slack when you create the webhook at
		# https://my.slack.com/services/new/incoming-webhook/
		send_slack_message('<YOUR MESSAGE BODY>', '<SLACK CHANNEL URL>')











"""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       SCREAMING_SNAKE_CASE__					(					nn.Module					):
						_a    						=						42
						_a    						=						42
						_a    						=						0.0
						_a    						=						1
						_a    						=						1
						_a    						=						True
						_a    						=						False
						_a    						=						False
						_a    						=						False
						_a    						=						jnp.floataa


						def   __lowercase (							self				:			List[str]					):
										lowerCAmelCase  =				[]
										lowerCAmelCase  =				[]

										for i in range(self.num_layers					):
														lowerCAmelCase  =				self.in_channels if i == 0 else self.out_channels

														lowerCAmelCase  =				FlaxResnetBlockaD(
														    in_channels=lowerCAmelCase						,						out_channels=self.out_channels						,						dropout_prob=self.dropout						,						dtype=self.dtype						,						)
														resnets.append(lowerCAmelCase					)

														lowerCAmelCase  =				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(lowerCAmelCase					)

										lowerCAmelCase  =				resnets
										lowerCAmelCase  =				attentions

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




						def __call__(							self				:			Tuple						,						lowerCAmelCase				:			str						,						lowerCAmelCase				:			Union[str, Any]						,						lowerCAmelCase				:			Tuple						,						lowerCAmelCase				:			int=True					):
										lowerCAmelCase  =				()

										for resnet, attn in zip(self.resnets						,						self.attentions					):
														lowerCAmelCase  =				resnet(lowerCAmelCase						,						lowerCAmelCase						,						deterministic=lowerCAmelCase					)
														lowerCAmelCase  =				attn(lowerCAmelCase						,						lowerCAmelCase						,						deterministic=lowerCAmelCase					)
														output_states += (hidden_states,)

										if self.add_downsample:
														lowerCAmelCase  =				self.downsamplers_a(lowerCAmelCase					)
														output_states += (hidden_states,)

										return hidden_states, output_states






class       SCREAMING_SNAKE_CASE__					(					nn.Module					):
						_a    						=						42
						_a    						=						42
						_a    						=						0.0
						_a    						=						1
						_a    						=						True
						_a    						=						jnp.floataa


						def   __lowercase (							self				:			Union[str, Any]					):
										lowerCAmelCase  =				[]

										for i in range(self.num_layers					):
														lowerCAmelCase  =				self.in_channels if i == 0 else self.out_channels

														lowerCAmelCase  =				FlaxResnetBlockaD(
														    in_channels=lowerCAmelCase						,						out_channels=self.out_channels						,						dropout_prob=self.dropout						,						dtype=self.dtype						,						)
														resnets.append(lowerCAmelCase					)
										lowerCAmelCase  =				resnets

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




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

										for resnet in self.resnets:
														lowerCAmelCase  =				resnet(lowerCAmelCase						,						lowerCAmelCase						,						deterministic=lowerCAmelCase					)
														output_states += (hidden_states,)

										if self.add_downsample:
														lowerCAmelCase  =				self.downsamplers_a(lowerCAmelCase					)
														output_states += (hidden_states,)

										return hidden_states, output_states






class       SCREAMING_SNAKE_CASE__					(					nn.Module					):
						_a    						=						42
						_a    						=						42
						_a    						=						42
						_a    						=						0.0
						_a    						=						1
						_a    						=						1
						_a    						=						True
						_a    						=						False
						_a    						=						False
						_a    						=						False
						_a    						=						jnp.floataa


						def   __lowercase (							self				:			List[str]					):
										lowerCAmelCase  =				[]
										lowerCAmelCase  =				[]

										for i in range(self.num_layers					):
														lowerCAmelCase  =				self.in_channels if (i == self.num_layers - 1) else self.out_channels
														lowerCAmelCase  =				self.prev_output_channel if i == 0 else self.out_channels

														lowerCAmelCase  =				FlaxResnetBlockaD(
														    in_channels=resnet_in_channels + res_skip_channels						,						out_channels=self.out_channels						,						dropout_prob=self.dropout						,						dtype=self.dtype						,						)
														resnets.append(lowerCAmelCase					)

														lowerCAmelCase  =				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(lowerCAmelCase					)

										lowerCAmelCase  =				resnets
										lowerCAmelCase  =				attentions

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




						def __call__(							self				:			Optional[Any]						,						lowerCAmelCase				:			Tuple						,						lowerCAmelCase				:			Dict						,						lowerCAmelCase				:			List[Any]						,						lowerCAmelCase				:			Any						,						lowerCAmelCase				:			Dict=True					):
										for resnet, attn in zip(self.resnets						,						self.attentions					):
														# pop res hidden states
														lowerCAmelCase  =				res_hidden_states_tuple[-1]
														lowerCAmelCase  =				res_hidden_states_tuple[:-1]
														lowerCAmelCase  =				jnp.concatenate((hidden_states, res_hidden_states)						,						axis=-1					)

														lowerCAmelCase  =				resnet(lowerCAmelCase						,						lowerCAmelCase						,						deterministic=lowerCAmelCase					)
														lowerCAmelCase  =				attn(lowerCAmelCase						,						lowerCAmelCase						,						deterministic=lowerCAmelCase					)

										if self.add_upsample:
														lowerCAmelCase  =				self.upsamplers_a(lowerCAmelCase					)

										return hidden_states






class       SCREAMING_SNAKE_CASE__					(					nn.Module					):
						_a    						=						42
						_a    						=						42
						_a    						=						42
						_a    						=						0.0
						_a    						=						1
						_a    						=						True
						_a    						=						jnp.floataa


						def   __lowercase (							self				:			Tuple					):
										lowerCAmelCase  =				[]

										for i in range(self.num_layers					):
														lowerCAmelCase  =				self.in_channels if (i == self.num_layers - 1) else self.out_channels
														lowerCAmelCase  =				self.prev_output_channel if i == 0 else self.out_channels

														lowerCAmelCase  =				FlaxResnetBlockaD(
														    in_channels=resnet_in_channels + res_skip_channels						,						out_channels=self.out_channels						,						dropout_prob=self.dropout						,						dtype=self.dtype						,						)
														resnets.append(lowerCAmelCase					)

										lowerCAmelCase  =				resnets

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




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

														lowerCAmelCase  =				resnet(lowerCAmelCase						,						lowerCAmelCase						,						deterministic=lowerCAmelCase					)

										if self.add_upsample:
														lowerCAmelCase  =				self.upsamplers_a(lowerCAmelCase					)

										return hidden_states






class       SCREAMING_SNAKE_CASE__					(					nn.Module					):
						_a    						=						42
						_a    						=						0.0
						_a    						=						1
						_a    						=						1
						_a    						=						False
						_a    						=						False
						_a    						=						jnp.floataa


						def   __lowercase (							self				:			List[Any]					):
										# there is always at least one resnet
										lowerCAmelCase  =				[
										    FlaxResnetBlockaD(
										        in_channels=self.in_channels						,						out_channels=self.in_channels						,						dropout_prob=self.dropout						,						dtype=self.dtype						,						)
										]

										lowerCAmelCase  =				[]

										for _ in range(self.num_layers					):
														lowerCAmelCase  =				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(lowerCAmelCase					)

														lowerCAmelCase  =				FlaxResnetBlockaD(
														    in_channels=self.in_channels						,						out_channels=self.in_channels						,						dropout_prob=self.dropout						,						dtype=self.dtype						,						)
														resnets.append(lowerCAmelCase					)

										lowerCAmelCase  =				resnets
										lowerCAmelCase  =				attentions




						def __call__(							self				:			Optional[int]						,						lowerCAmelCase				:			List[str]						,						lowerCAmelCase				:			int						,						lowerCAmelCase				:			Dict						,						lowerCAmelCase				:			List[Any]=True					):
										lowerCAmelCase  =				self.resnets[0](lowerCAmelCase						,						lowerCAmelCase					)
										for attn, resnet in zip(self.attentions						,						self.resnets[1:]					):
														lowerCAmelCase  =				attn(lowerCAmelCase						,						lowerCAmelCase						,						deterministic=lowerCAmelCase					)
														lowerCAmelCase  =				resnet(lowerCAmelCase						,						lowerCAmelCase						,						deterministic=lowerCAmelCase					)

										return hidden_states





