






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



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

    lowerCamelCase	:							int
    lowerCamelCase	:							jnp.dtype				= jnp.floataa



    def _a							(				self      :     Union[str, Any]      )      ->							List[Any]:
           __UpperCAmelCase     				=nn.Conv(
               self.out_channels ,     kernel_size=(3, 3) ,     strides=(1, 1) ,     padding=((1, 1), (1, 1)) ,     dtype=self.dtype ,     )



    def __call__(				self      :     Any ,     __SCREAMING_SNAKE_CASE      :     List[Any]      )      ->							str:
           __UpperCAmelCase				, __UpperCAmelCase				, __UpperCAmelCase				, __UpperCAmelCase     				=hidden_states.shape
           __UpperCAmelCase     				=jax.image.resize(
               __SCREAMING_SNAKE_CASE ,     shape=(batch, height * 2, width * 2, channels) ,     method="""nearest""" ,     )
           __UpperCAmelCase     				=self.conv(__SCREAMING_SNAKE_CASE      )
           return hidden_states




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

    lowerCamelCase	:							int
    lowerCamelCase	:							jnp.dtype				= jnp.floataa



    def _a							(				self      :     List[str]      )      ->							Any:
           __UpperCAmelCase     				=nn.Conv(
               self.out_channels ,     kernel_size=(3, 3) ,     strides=(2, 2) ,     padding=((1, 1), (1, 1)) ,     dtype=self.dtype ,     )



    def __call__(				self      :     Any ,     __SCREAMING_SNAKE_CASE      :     List[Any]      )      ->							Tuple:
           # pad = ((0, 0), (0, 1), (0, 1), (0, 0))  # pad height and width dim
           # hidden_states = jnp.pad(hidden_states, pad_width=pad)
           __UpperCAmelCase     				=self.conv(__SCREAMING_SNAKE_CASE      )
           return hidden_states




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

    lowerCamelCase	:							int
    lowerCamelCase	:							int				= None
    lowerCamelCase	:							float				= 0.0
    lowerCamelCase	:							bool				= None
    lowerCamelCase	:							jnp.dtype				= jnp.floataa



    def _a							(				self      :     Union[str, Any]      )      ->							Tuple:
           __UpperCAmelCase     				=self.in_channels if self.out_channels is None else self.out_channels

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

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

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

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

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



    def __call__(				self      :     Optional[Any] ,     __SCREAMING_SNAKE_CASE      :     Dict ,     __SCREAMING_SNAKE_CASE      :     Optional[Any] ,     __SCREAMING_SNAKE_CASE      :     Dict=True      )      ->							Dict:
           __UpperCAmelCase     				=hidden_states
           __UpperCAmelCase     				=self.norma(__SCREAMING_SNAKE_CASE      )
           __UpperCAmelCase     				=nn.swish(__SCREAMING_SNAKE_CASE      )
           __UpperCAmelCase     				=self.conva(__SCREAMING_SNAKE_CASE      )

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

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

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

           return hidden_states + residual









'''simple docstring'''





def 							lowerCamelCase	(					_snake_case	:    Optional[Any]  ,_snake_case	:    Union[str, Any]  ,_snake_case	:    Dict  ,_snake_case	:    List[str]  ,_snake_case	:    List[str]  ,_snake_case	:    List[str]							):





    '''simple docstring'''


    if index == r:
        for j in range(_snake_case							):
            print(data[j]  ,end=" "							)
        print(" "							)
        return
    #  When no more elements are there to put in data[]
    if i >= n:
        return
    # current is included, put next at next location
    lowercase__									=    arr[i]
    combination_util(_snake_case  ,_snake_case  ,_snake_case  ,index + 1  ,_snake_case  ,i + 1							)
    # current is excluded, replace it with
    # next (Note that i+1 is passed, but
    # index is not changed)
    combination_util(_snake_case  ,_snake_case  ,_snake_case  ,_snake_case  ,_snake_case  ,i + 1							)
    # The main function that prints all combinations
    # of size r in arr[] of size n. This function
    # mainly uses combinationUtil()




def 							lowerCamelCase	(					_snake_case	:    Optional[Any]  ,_snake_case	:    Tuple  ,_snake_case	:    Union[str, Any]							):





    '''simple docstring'''


    lowercase__									=    [0] * r
    # Print all combination using temporary array 'data[]'
    combination_util(_snake_case  ,_snake_case  ,_snake_case  ,0  ,_snake_case  ,0							)


if __name__ == "__main__":
 # Driver code to check the function above
 SCREAMING_SNAKE_CASE__          =  [10, 20, 30, 40, 50]
 print_combination(arr, len(arr), 3)
 # This code is contributed by Ambuj sahu




