





a        =						"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"

def 						__magic_name__       (							__UpperCAmelCase      )						->					int:

   '''simple docstring'''







   if not isinstance(_lowerCAmelCase							,	_lowerCAmelCase      ):
      __SCREAMING_SNAKE_CASE      							=       f"""a bytes-like object is required, not '{data.__class__.__name__}'"""
      raise TypeError(_lowerCAmelCase      )

   __SCREAMING_SNAKE_CASE      							=       """""".join(bin(_lowerCAmelCase      )[2:].zfill(8      ) for byte in data      )

   __SCREAMING_SNAKE_CASE      							=       len(_lowerCAmelCase      ) % 6 != 0

   if padding_needed:
      # The padding that will be added later
      __SCREAMING_SNAKE_CASE      							=       b"""=""" * ((6 - len(_lowerCAmelCase      ) % 6) // 2)

      # Append binary_stream with arbitrary binary digits (0's by default) to make its
      # length a multiple of 6.
      binary_stream += "0" * (6 - len(_lowerCAmelCase      ) % 6)
   else:
      __SCREAMING_SNAKE_CASE      							=       b""""""

   # Encode every 6 binary digits to their corresponding Base64 character
   return (
       "".join(
           B64_CHARSET[int(binary_stream[index : index + 6]							,	2      )]
           for index in range(0							,	len(_lowerCAmelCase      )							,	6      )      ).encode()
       + padding
   )

def 						__magic_name__       (							__UpperCAmelCase      )						->					List[Any]:

   '''simple docstring'''







   if not isinstance(_lowerCAmelCase							,	_lowerCAmelCase      ) and not isinstance(_lowerCAmelCase							,	_lowerCAmelCase      ):
      __SCREAMING_SNAKE_CASE      							=       (
          """argument should be a bytes-like object or ASCII string, """
          f"""not '{encoded_data.__class__.__name__}'"""
      )
      raise TypeError(_lowerCAmelCase      )

   # In case encoded_data is a bytes-like object, make sure it contains only
   # ASCII characters so we convert it to a string object
   if isinstance(_lowerCAmelCase							,	_lowerCAmelCase      ):
      try:
         __SCREAMING_SNAKE_CASE      							=       encoded_data.decode("""utf-8"""      )
      except UnicodeDecodeError:
         raise ValueError("""base64 encoded data should only contain ASCII characters"""      )

   __SCREAMING_SNAKE_CASE      							=       encoded_data.count("""="""      )

   # Check if the encoded string contains non base64 characters
   if padding:
      assert all(
          char in B64_CHARSET for char in encoded_data[:-padding]      ), "Invalid base64 character(s) found."
   else:
      assert all(
          char in B64_CHARSET for char in encoded_data      ), "Invalid base64 character(s) found."

   # Check the padding
   assert len(_lowerCAmelCase      ) % 4 == 0 and padding < 3, "Incorrect padding"

   if padding:
      # Remove padding if there is one
      __SCREAMING_SNAKE_CASE      							=       encoded_data[:-padding]

      __SCREAMING_SNAKE_CASE      							=       """""".join(
          bin(B64_CHARSET.index(_lowerCAmelCase      )      )[2:].zfill(6      ) for char in encoded_data      )[: -padding * 2]
   else:
      __SCREAMING_SNAKE_CASE      							=       """""".join(
          bin(B64_CHARSET.index(_lowerCAmelCase      )      )[2:].zfill(6      ) for char in encoded_data      )

   __SCREAMING_SNAKE_CASE      							=       [
       int(binary_stream[index : index + 8]							,	2      )
       for index in range(0							,	len(_lowerCAmelCase      )							,	8      )
   ]

   return bytes(_lowerCAmelCase      )


if __name__ == "__main__":
    import doctest

    doctest.testmod()












'''simple docstring'''

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







class __a (   nn.Module			):
   __UpperCamelCase   : int
   __UpperCamelCase   : jnp.dtype	      =	jnp.floataa





   def      UpperCAmelCase__     (					self				:			List[Any]    ):

      '''simple docstring'''

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





   def __call__(					self				:			List[Any]				,lowerCamelCase				:			Tuple    ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE							,     __SCREAMING_SNAKE_CASE							,     __SCREAMING_SNAKE_CASE							,     __SCREAMING_SNAKE_CASE      							=       hidden_states.shape
      __SCREAMING_SNAKE_CASE      							=       jax.image.resize(
          lowerCamelCase				,shape=(batch, height * 2, width * 2, channels)				,method="""nearest"""				,)
      __SCREAMING_SNAKE_CASE      							=       self.conv(lowerCamelCase    )
      return hidden_states







class __a (   nn.Module			):
   __UpperCamelCase   : int
   __UpperCamelCase   : jnp.dtype	      =	jnp.floataa





   def      UpperCAmelCase__     (					self				:			Optional[int]    ):

      '''simple docstring'''

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





   def __call__(					self				:			List[str]				,lowerCamelCase				:			Tuple    ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE      							=       self.conv(lowerCamelCase    )
      return hidden_states







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





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

      '''simple docstring'''

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

      __SCREAMING_SNAKE_CASE      							=       nn.GroupNorm(num_groups=32				,epsilon=1E-5    )
      __SCREAMING_SNAKE_CASE      							=       nn.Conv(
          lowerCamelCase				,kernel_size=(3, 3)				,strides=(1, 1)				,padding=((1, 1), (1, 1))				,dtype=self.dtype				,)

      __SCREAMING_SNAKE_CASE      							=       nn.Dense(lowerCamelCase				,dtype=self.dtype    )

      __SCREAMING_SNAKE_CASE      							=       nn.GroupNorm(num_groups=32				,epsilon=1E-5    )
      __SCREAMING_SNAKE_CASE      							=       nn.Dropout(self.dropout_prob    )
      __SCREAMING_SNAKE_CASE      							=       nn.Conv(
          lowerCamelCase				,kernel_size=(3, 3)				,strides=(1, 1)				,padding=((1, 1), (1, 1))				,dtype=self.dtype				,)

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

      __SCREAMING_SNAKE_CASE      							=       None
      if use_nin_shortcut:
         __SCREAMING_SNAKE_CASE      							=       nn.Conv(
             lowerCamelCase				,kernel_size=(1, 1)				,strides=(1, 1)				,padding="""VALID"""				,dtype=self.dtype				,)





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

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE      							=       hidden_states
      __SCREAMING_SNAKE_CASE      							=       self.norma(lowerCamelCase    )
      __SCREAMING_SNAKE_CASE      							=       nn.swish(lowerCamelCase    )
      __SCREAMING_SNAKE_CASE      							=       self.conva(lowerCamelCase    )

      __SCREAMING_SNAKE_CASE      							=       self.time_emb_proj(nn.swish(lowerCamelCase    )    )
      __SCREAMING_SNAKE_CASE      							=       jnp.expand_dims(jnp.expand_dims(lowerCamelCase				,1    )				,1    )
      __SCREAMING_SNAKE_CASE      							=       hidden_states + temb

      __SCREAMING_SNAKE_CASE      							=       self.norma(lowerCamelCase    )
      __SCREAMING_SNAKE_CASE      							=       nn.swish(lowerCamelCase    )
      __SCREAMING_SNAKE_CASE      							=       self.dropout(lowerCamelCase				,lowerCamelCase    )
      __SCREAMING_SNAKE_CASE      							=       self.conva(lowerCamelCase    )

      if self.conv_shortcut is not None:
         __SCREAMING_SNAKE_CASE      							=       self.conv_shortcut(lowerCamelCase    )

      return hidden_states + residual





