'''simple docstring'''




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





class 							SCREAMING_SNAKE_CASE (					nn.Module			):
  """simple docstring"""







  __A  =		42
  __A  =		jnp.floataa



  def 	a (	self :       int       ):


        """simple docstring"""



        _lowerCAmelCase		 = nn.Conv(
            self.out_channels       ,       kernel_size=(3, 3)       ,       strides=(1, 1)       ,       padding=((1, 1), (1, 1))       ,       dtype=self.dtype       ,       )



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


        """simple docstring"""



        _lowerCAmelCase ,	_lowerCAmelCase ,	_lowerCAmelCase ,	_lowerCAmelCase		 = hidden_states.shape
        _lowerCAmelCase		 = jax.image.resize(
            __lowerCAmelCase       ,       shape=(batch, height * 2, width * 2, channels)       ,       method='nearest'       ,       )
        _lowerCAmelCase		 = self.conv(__lowerCAmelCase       )
        return hidden_states





class 							SCREAMING_SNAKE_CASE (					nn.Module			):
  """simple docstring"""







  __A  =		42
  __A  =		jnp.floataa



  def 	a (	self :       Dict       ):


        """simple docstring"""



        _lowerCAmelCase		 = nn.Conv(
            self.out_channels       ,       kernel_size=(3, 3)       ,       strides=(2, 2)       ,       padding=((1, 1), (1, 1))       ,       dtype=self.dtype       ,       )



  def __call__(	self :       str       ,       __lowerCAmelCase :       Dict       ):


        """simple docstring"""



        _lowerCAmelCase		 = self.conv(__lowerCAmelCase       )
        return hidden_states





class 							SCREAMING_SNAKE_CASE (					nn.Module			):
  """simple docstring"""







  __A  =		42
  __A  =		None
  __A  =		0.0
  __A  =		None
  __A  =		jnp.floataa



  def 	a (	self :       Dict       ):


        """simple docstring"""



        _lowerCAmelCase		 = self.in_channels if self.out_channels is None else self.out_channels

        _lowerCAmelCase		 = nn.GroupNorm(num_groups=32       ,       epsilon=1e-5       )
        _lowerCAmelCase		 = nn.Conv(
            __lowerCAmelCase       ,       kernel_size=(3, 3)       ,       strides=(1, 1)       ,       padding=((1, 1), (1, 1))       ,       dtype=self.dtype       ,       )

        _lowerCAmelCase		 = nn.Dense(__lowerCAmelCase       ,       dtype=self.dtype       )

        _lowerCAmelCase		 = nn.GroupNorm(num_groups=32       ,       epsilon=1e-5       )
        _lowerCAmelCase		 = nn.Dropout(self.dropout_prob       )
        _lowerCAmelCase		 = nn.Conv(
            __lowerCAmelCase       ,       kernel_size=(3, 3)       ,       strides=(1, 1)       ,       padding=((1, 1), (1, 1))       ,       dtype=self.dtype       ,       )

        _lowerCAmelCase		 = self.in_channels != out_channels if self.use_nin_shortcut is None else self.use_nin_shortcut

        _lowerCAmelCase		 = None
        if use_nin_shortcut:
              _lowerCAmelCase		 = nn.Conv(
                  __lowerCAmelCase       ,       kernel_size=(1, 1)       ,       strides=(1, 1)       ,       padding='VALID'       ,       dtype=self.dtype       ,       )



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


        """simple docstring"""



        _lowerCAmelCase		 = hidden_states
        _lowerCAmelCase		 = self.norma(__lowerCAmelCase       )
        _lowerCAmelCase		 = nn.swish(__lowerCAmelCase       )
        _lowerCAmelCase		 = self.conva(__lowerCAmelCase       )

        _lowerCAmelCase		 = self.time_emb_proj(nn.swish(__lowerCAmelCase       )       )
        _lowerCAmelCase		 = jnp.expand_dims(jnp.expand_dims(__lowerCAmelCase       ,       1       )       ,       1       )
        _lowerCAmelCase		 = hidden_states + temb

        _lowerCAmelCase		 = self.norma(__lowerCAmelCase       )
        _lowerCAmelCase		 = nn.swish(__lowerCAmelCase       )
        _lowerCAmelCase		 = self.dropout(__lowerCAmelCase       ,       __lowerCAmelCase       )
        _lowerCAmelCase		 = self.conva(__lowerCAmelCase       )

        if self.conv_shortcut is not None:
              _lowerCAmelCase		 = self.conv_shortcut(__lowerCAmelCase       )

        return hidden_states + residual









'''simple docstring'''

def _SCREAMING_SNAKE_CASE (A			)			->			bool:






       """simple docstring"""







       if not isinstance(A    ,					A			):
              raise ValueError('''Input series is not valid, valid series - [2, 4, 6]'''			)
       if len(A			) == 0:
              raise ValueError('''Input list must be a non empty list'''			)
       if len(A			) == 1:
              return True
       lowercase__      =					series[1] - series[0]
       for index in range(len(A			) - 1			):
              if series[index + 1] - series[index] != common_diff:
                     return False
       return True

def _SCREAMING_SNAKE_CASE (A			)			->			float:






       """simple docstring"""







       if not isinstance(A    ,					A			):
              raise ValueError('''Input series is not valid, valid series - [2, 4, 6]'''			)
       if len(A			) == 0:
              raise ValueError('''Input list must be a non empty list'''			)
       lowercase__      =					0
       for val in series:
              answer += val
       return answer / len(A			)


if __name__ == "__main__":
 import doctest

 doctest.testmod()




