





'''simple docstring'''






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


class   _lowercase						(							nn.Module				):
   _UpperCamelCase       		=   42
   _UpperCamelCase       		=   jnp.floataa


   def 					snake_case				( self					):
       A       :       Union[str, Any]							=						nn.Conv(
           self.out_channels    ,   kernel_size=(3, 3)    ,   strides=(1, 1)    ,   padding=((1, 1), (1, 1))    ,   dtype=self.dtype    ,   )


   def __call__( self    ,   _UpperCAmelCase					):
       A       :       Optional[int]							=						hidden_states.shape
       A       :       Union[str, Any]							=						jax.image.resize(
           _UpperCAmelCase    ,   shape=(batch, height * 2, width * 2, channels)    ,   method='''nearest'''    ,   )
       A       :       Optional[Any]							=						self.conv(_UpperCAmelCase					)
       return hidden_states







class   _lowercase						(							nn.Module				):
   _UpperCamelCase       		=   42
   _UpperCamelCase       		=   jnp.floataa


   def 					snake_case				( self					):
       A       :       Dict							=						nn.Conv(
           self.out_channels    ,   kernel_size=(3, 3)    ,   strides=(2, 2)    ,   padding=((1, 1), (1, 1))    ,   dtype=self.dtype    ,   )


   def __call__( self    ,   _UpperCAmelCase					):
       # pad = ((0, 0), (0, 1), (0, 1), (0, 0))  # pad height and width dim
       # hidden_states = jnp.pad(hidden_states, pad_width=pad)
       A       :       str							=						self.conv(_UpperCAmelCase					)
       return hidden_states







class   _lowercase						(							nn.Module				):
   _UpperCamelCase       		=   42
   _UpperCamelCase       		=   None
   _UpperCamelCase       		=   0.0
   _UpperCamelCase       		=   None
   _UpperCamelCase       		=   jnp.floataa


   def 					snake_case				( self					):
       A       :       Optional[int]							=						self.in_channels if self.out_channels is None else self.out_channels

       A       :       Dict							=						nn.GroupNorm(num_groups=32    ,   epsilon=1E-5					)
       A       :       Optional[int]							=						nn.Conv(
           _UpperCAmelCase    ,   kernel_size=(3, 3)    ,   strides=(1, 1)    ,   padding=((1, 1), (1, 1))    ,   dtype=self.dtype    ,   )

       A       :       Optional[Any]							=						nn.Dense(_UpperCAmelCase    ,   dtype=self.dtype					)

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

       A       :       str							=						self.in_channels != out_channels if self.use_nin_shortcut is None else self.use_nin_shortcut

       A       :       int							=						None
       if use_nin_shortcut:
           A       :       List[str]							=						nn.Conv(
               _UpperCAmelCase    ,   kernel_size=(1, 1)    ,   strides=(1, 1)    ,   padding='''VALID'''    ,   dtype=self.dtype    ,   )


   def __call__( self    ,   _UpperCAmelCase    ,   _UpperCAmelCase    ,   _UpperCAmelCase=True					):
       A       :       List[str]							=						hidden_states
       A       :       Union[str, Any]							=						self.norma(_UpperCAmelCase					)
       A       :       Union[str, Any]							=						nn.swish(_UpperCAmelCase					)
       A       :       List[Any]							=						self.conva(_UpperCAmelCase					)

       A       :       Optional[Any]							=						self.time_emb_proj(nn.swish(_UpperCAmelCase					)					)
       A       :       List[str]							=						jnp.expand_dims(jnp.expand_dims(_UpperCAmelCase    ,   1					)    ,   1					)
       A       :       Dict							=						hidden_states + temb

       A       :       Union[str, Any]							=						self.norma(_UpperCAmelCase					)
       A       :       Dict							=						nn.swish(_UpperCAmelCase					)
       A       :       str							=						self.dropout(_UpperCAmelCase    ,   _UpperCAmelCase					)
       A       :       List[str]							=						self.conva(_UpperCAmelCase					)

       if self.conv_shortcut is not None:
           A       :       List[Any]							=						self.conv_shortcut(_UpperCAmelCase					)

       return hidden_states + residual







'''simple docstring'''






from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_sentencepiece_available,
    is_torch_available,
)


snake_case_     =	{
    """configuration_speecht5""": [
        """SPEECHT5_PRETRAINED_CONFIG_ARCHIVE_MAP""",
        """SPEECHT5_PRETRAINED_HIFIGAN_CONFIG_ARCHIVE_MAP""",
        """SpeechT5Config""",
        """SpeechT5HifiGanConfig""",
    ],
    """feature_extraction_speecht5""": ["""SpeechT5FeatureExtractor"""],
    """processing_speecht5""": ["""SpeechT5Processor"""],
}

try:
     if not is_sentencepiece_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     snake_case_     =	["""SpeechT5Tokenizer"""]

try:
     if not is_torch_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     snake_case_     =	[
         """SPEECHT5_PRETRAINED_MODEL_ARCHIVE_LIST""",
         """SpeechT5ForSpeechToText""",
         """SpeechT5ForSpeechToSpeech""",
         """SpeechT5ForTextToSpeech""",
         """SpeechT5Model""",
         """SpeechT5PreTrainedModel""",
         """SpeechT5HifiGan""",
     ]

if TYPE_CHECKING:
     from .configuration_speechta import (
         SPEECHT5_PRETRAINED_CONFIG_ARCHIVE_MAP,
         SPEECHT5_PRETRAINED_HIFIGAN_CONFIG_ARCHIVE_MAP,
         SpeechTaConfig,
         SpeechTaHifiGanConfig,
     )
     from .feature_extraction_speechta import SpeechTaFeatureExtractor
     from .processing_speechta import SpeechTaProcessor

     try:
          if not is_sentencepiece_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .tokenization_speechta import SpeechTaTokenizer

     try:
          if not is_torch_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_speechta import (
              SPEECHT5_PRETRAINED_MODEL_ARCHIVE_LIST,
              SpeechTaForSpeechToSpeech,
              SpeechTaForSpeechToText,
              SpeechTaForTextToSpeech,
              SpeechTaHifiGan,
              SpeechTaModel,
              SpeechTaPreTrainedModel,
          )

else:
     import sys

     snake_case_     =	_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)
