



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

class     _A       (	nn.Module    ):
       UpperCamelCase__  :    int
       UpperCamelCase__  :    jnp.dtype											=						jnp.floataa



       def 		_lowerCamelCase			(		self							:     List[str]):


           '''simple docstring'''

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





       def __call__(		self							:     Tuple     ,		__SCREAMING_SNAKE_CASE							:     str):


           '''simple docstring'''

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


class     _A       (	nn.Module    ):
       UpperCamelCase__  :    int
       UpperCamelCase__  :    jnp.dtype											=						jnp.floataa



       def 		_lowerCamelCase			(		self							:     Optional[Any]):


           '''simple docstring'''

           __a						       =				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]     ,		__SCREAMING_SNAKE_CASE							:     Optional[int]):


           '''simple docstring'''

           __a						       =				self.conv(__SCREAMING_SNAKE_CASE)
           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 		_lowerCamelCase			(		self							:     Optional[int]):


           '''simple docstring'''

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

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

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

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

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

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





       def __call__(		self							:     str     ,		__SCREAMING_SNAKE_CASE							:     Any     ,		__SCREAMING_SNAKE_CASE							:     Optional[Any]     ,		__SCREAMING_SNAKE_CASE							:     int=True):


           '''simple docstring'''

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

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

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

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

           return hidden_states + residual












'''simple docstring'''

from ...utils import (
    OptionalDependencyNotAvailable,
    is_torch_available,
    is_transformers_available,
    is_transformers_version,
)


try:
      if not (is_transformers_available() and is_torch_available()):
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      from ...utils.dummy_torch_and_transformers_objects import (
          ImageTextPipelineOutput,
          UniDiffuserPipeline,
      )
else:
      from .modeling_text_decoder import UniDiffuserTextDecoder
      from .modeling_uvit import UniDiffuserModel, UTransformeraDModel
      from .pipeline_unidiffuser import ImageTextPipelineOutput, UniDiffuserPipeline



