


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

class       __magic_name__	(     nn.Module):
     A:		int
     A:		jnp.dtype			=      jnp.floataa


     def      UpperCAmelCase__	(      self							:     Optional[Any]			)  ->      Optional[int]:





      '''simple docstring'''






      UpperCamelCase__					:    Dict          =   nn.Conv(
          self.out_channels							,	kernel_size=(3, 3)							,	strides=(1, 1)							,	padding=((1, 1), (1, 1))							,	dtype=self.dtype							,	)


     def __call__(      self							:     int							,	lowerCamelCase__							:     List[Any]			)  ->      Optional[int]:





      '''simple docstring'''






      UpperCamelCase__					:    Optional[Any]          =   hidden_states.shape
      UpperCamelCase__					:    List[Any]          =   jax.image.resize(
          lowerCamelCase__							,	shape=(batch, height * 2, width * 2, channels)							,	method='''nearest'''							,	)
      UpperCamelCase__					:    Any          =   self.conv(lowerCamelCase__			)
      return hidden_states



class       __magic_name__	(     nn.Module):
     A:		int
     A:		jnp.dtype			=      jnp.floataa


     def      UpperCAmelCase__	(      self							:     Optional[int]			)  ->      str:





      '''simple docstring'''






      UpperCamelCase__					:    List[str]          =   nn.Conv(
          self.out_channels							,	kernel_size=(3, 3)							,	strides=(2, 2)							,	padding=((1, 1), (1, 1))							,	dtype=self.dtype							,	)


     def __call__(      self							:     Union[str, Any]							,	lowerCamelCase__							:     Union[str, Any]			)  ->      int:





      '''simple docstring'''






      UpperCamelCase__					:    List[str]          =   self.conv(lowerCamelCase__			)
      return hidden_states



class       __magic_name__	(     nn.Module):
     A:		int
     A:		int			=      None
     A:		float			=      0.0
     A:		bool			=      None
     A:		jnp.dtype			=      jnp.floataa


     def      UpperCAmelCase__	(      self							:     List[str]			)  ->      Dict:





      '''simple docstring'''






      UpperCamelCase__					:    str          =   self.in_channels if self.out_channels is None else self.out_channels

      UpperCamelCase__					:    Any          =   nn.GroupNorm(num_groups=32							,	epsilon=1E-5			)
      UpperCamelCase__					:    Tuple          =   nn.Conv(
          lowerCamelCase__							,	kernel_size=(3, 3)							,	strides=(1, 1)							,	padding=((1, 1), (1, 1))							,	dtype=self.dtype							,	)

      UpperCamelCase__					:    Union[str, Any]          =   nn.Dense(lowerCamelCase__							,	dtype=self.dtype			)

      UpperCamelCase__					:    Optional[Any]          =   nn.GroupNorm(num_groups=32							,	epsilon=1E-5			)
      UpperCamelCase__					:    Tuple          =   nn.Dropout(self.dropout_prob			)
      UpperCamelCase__					:    List[str]          =   nn.Conv(
          lowerCamelCase__							,	kernel_size=(3, 3)							,	strides=(1, 1)							,	padding=((1, 1), (1, 1))							,	dtype=self.dtype							,	)

      UpperCamelCase__					:    Optional[int]          =   self.in_channels != out_channels if self.use_nin_shortcut is None else self.use_nin_shortcut

      UpperCamelCase__					:    Optional[Any]          =   None
      if use_nin_shortcut:
       UpperCamelCase__					:    List[str]          =   nn.Conv(
           lowerCamelCase__							,	kernel_size=(1, 1)							,	strides=(1, 1)							,	padding='''VALID'''							,	dtype=self.dtype							,	)


     def __call__(      self							:     Any							,	lowerCamelCase__							:     Union[str, Any]							,	lowerCamelCase__							:     Union[str, Any]							,	lowerCamelCase__							:     List[str]=True			)  ->      Union[str, Any]:





      '''simple docstring'''






      UpperCamelCase__					:    Optional[int]          =   hidden_states
      UpperCamelCase__					:    int          =   self.norma(lowerCamelCase__			)
      UpperCamelCase__					:    List[str]          =   nn.swish(lowerCamelCase__			)
      UpperCamelCase__					:    Tuple          =   self.conva(lowerCamelCase__			)

      UpperCamelCase__					:    List[str]          =   self.time_emb_proj(nn.swish(lowerCamelCase__			)			)
      UpperCamelCase__					:    str          =   jnp.expand_dims(jnp.expand_dims(lowerCamelCase__							,	1			)							,	1			)
      UpperCamelCase__					:    Tuple          =   hidden_states + temb

      UpperCamelCase__					:    Dict          =   self.norma(lowerCamelCase__			)
      UpperCamelCase__					:    int          =   nn.swish(lowerCamelCase__			)
      UpperCamelCase__					:    str          =   self.dropout(lowerCamelCase__							,	lowerCamelCase__			)
      UpperCamelCase__					:    int          =   self.conva(lowerCamelCase__			)

      if self.conv_shortcut is not None:
       UpperCamelCase__					:    str          =   self.conv_shortcut(lowerCamelCase__			)

      return hidden_states + residual






__UpperCamelCase       :       List[Any]						       =				256
# Modulus to hash a string
__UpperCamelCase       :       Union[str, Any]						       =				100_0003

def 			_a  (				SCREAMING_SNAKE_CASE	:				str    , SCREAMING_SNAKE_CASE	:				str     ):







 """simple docstring"""



 UpperCamelCase__					:    Optional[int]          =   len(SCREAMING_SNAKE_CASE     )
 UpperCamelCase__					:    List[Any]          =   len(SCREAMING_SNAKE_CASE     )
 if p_len > t_len:
  return False

 UpperCamelCase__					:    Any          =   0
 UpperCamelCase__					:    str          =   0
 UpperCamelCase__					:    List[Any]          =   1

 # Calculating the hash of pattern and substring of text
 for i in range(SCREAMING_SNAKE_CASE     ):
  UpperCamelCase__					:    Any          =   (ord(pattern[i]     ) + p_hash * alphabet_size) % modulus
  UpperCamelCase__					:    List[str]          =   (ord(text[i]     ) + text_hash * alphabet_size) % modulus
  if i == p_len - 1:
   continue
  UpperCamelCase__					:    Dict          =   (modulus_power * alphabet_size) % modulus

 for i in range(0    , t_len - p_len + 1     ):
  if text_hash == p_hash and text[i : i + p_len] == pattern:
   return True
  if i == t_len - p_len:
   continue
  # Calculate the https://en.wikipedia.org/wiki/Rolling_hash
  UpperCamelCase__					:    Optional[int]          =   (
      (text_hash - ord(text[i]     ) * modulus_power) * alphabet_size
      + ord(text[i + p_len]     )
  ) % modulus
 return False

def 			_a  (				):







 """simple docstring"""



 UpperCamelCase__					:    Tuple          =   '''abc1abc12'''
 UpperCamelCase__					:    Dict          =   '''alskfjaldsabc1abc1abc12k23adsfabcabc'''
 UpperCamelCase__					:    List[str]          =   '''alskfjaldsk23adsfabcabc'''
 assert rabin_karp(SCREAMING_SNAKE_CASE    , SCREAMING_SNAKE_CASE     ) and not rabin_karp(SCREAMING_SNAKE_CASE    , SCREAMING_SNAKE_CASE     )

 # Test 2)
 UpperCamelCase__					:    Optional[int]          =   '''ABABX'''
 UpperCamelCase__					:    int          =   '''ABABZABABYABABX'''
 assert rabin_karp(SCREAMING_SNAKE_CASE    , SCREAMING_SNAKE_CASE     )

 # Test 3)
 UpperCamelCase__					:    int          =   '''AAAB'''
 UpperCamelCase__					:    str          =   '''ABAAAAAB'''
 assert rabin_karp(SCREAMING_SNAKE_CASE    , SCREAMING_SNAKE_CASE     )

 # Test 4)
 UpperCamelCase__					:    Union[str, Any]          =   '''abcdabcy'''
 UpperCamelCase__					:    List[str]          =   '''abcxabcdabxabcdabcdabcy'''
 assert rabin_karp(SCREAMING_SNAKE_CASE    , SCREAMING_SNAKE_CASE     )

 # Test 5)
 UpperCamelCase__					:    Tuple          =   '''Lü'''
 UpperCamelCase__					:    Any          =   '''Lüsai'''
 assert rabin_karp(SCREAMING_SNAKE_CASE    , SCREAMING_SNAKE_CASE     )
 UpperCamelCase__					:    Dict          =   '''Lue'''
 assert not rabin_karp(SCREAMING_SNAKE_CASE    , SCREAMING_SNAKE_CASE     )
 print('''Success.'''     )


if __name__ == "__main__":
       test_rabin_karp()


