

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





class 			_SCREAMING_SNAKE_CASE (   nn.Module		):







   '''simple docstring'''




   lowerCamelCase__				=      42
   lowerCamelCase__				=      jnp.floataa





   def      _snake_case		(       self					:			Tuple			):
       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					:			Optional[int]     , __lowerCamelCase					:			Union[str, Any]			):
       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 			_SCREAMING_SNAKE_CASE (   nn.Module		):







   '''simple docstring'''




   lowerCamelCase__				=      42
   lowerCamelCase__				=      jnp.floataa





   def      _snake_case		(       self					:			int			):
       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					:			Tuple     , __lowerCamelCase					:			List[Any]			):
       # pad = ((0, 0), (0, 1), (0, 1), (0, 0))  # pad height and width dim
       # hidden_states = jnp.pad(hidden_states, pad_width=pad)
       SCREAMING_SNAKE_CASE										=   self.conv(__lowerCamelCase			)
       return hidden_states





class 			_SCREAMING_SNAKE_CASE (   nn.Module		):







   '''simple docstring'''




   lowerCamelCase__				=      42
   lowerCamelCase__				=      None
   lowerCamelCase__				=      0.0
   lowerCamelCase__				=      None
   lowerCamelCase__				=      jnp.floataa





   def      _snake_case		(       self					:			int			):
       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					:			Any     , __lowerCamelCase					:			Tuple     , __lowerCamelCase					:			Dict     , __lowerCamelCase					:			Tuple=True			):
       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


from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


__A			:					Dict						=			{
    'configuration_bigbird_pegasus': [
        'BIGBIRD_PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP',
        'BigBirdPegasusConfig',
        'BigBirdPegasusOnnxConfig',
    ],
}

try:
    if not is_torch_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    __A			:					int						=			[
        'BIGBIRD_PEGASUS_PRETRAINED_MODEL_ARCHIVE_LIST',
        'BigBirdPegasusForCausalLM',
        'BigBirdPegasusForConditionalGeneration',
        'BigBirdPegasusForQuestionAnswering',
        'BigBirdPegasusForSequenceClassification',
        'BigBirdPegasusModel',
        'BigBirdPegasusPreTrainedModel',
    ]


if TYPE_CHECKING:
    from .configuration_bigbird_pegasus import (
        BIGBIRD_PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP,
        BigBirdPegasusConfig,
        BigBirdPegasusOnnxConfig,
    )

    try:
        if not is_torch_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_bigbird_pegasus import (
            BIGBIRD_PEGASUS_PRETRAINED_MODEL_ARCHIVE_LIST,
            BigBirdPegasusForCausalLM,
            BigBirdPegasusForConditionalGeneration,
            BigBirdPegasusForQuestionAnswering,
            BigBirdPegasusForSequenceClassification,
            BigBirdPegasusModel,
            BigBirdPegasusPreTrainedModel,
        )


else:
    import sys

    __A			:					List[Any]						=			_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)