






'''simple docstring'''
from collections import OrderedDict
from typing import Mapping

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


UpperCamelCase__			=      logging.get_logger(__name__)

UpperCamelCase__			=      {
    'facebook/xmod-base': 'https://huggingface.co/facebook/xmod-base/resolve/main/config.json',
    'facebook/xmod-large-prenorm': 'https://huggingface.co/facebook/xmod-large-prenorm/resolve/main/config.json',
    'facebook/xmod-base-13-125k': 'https://huggingface.co/facebook/xmod-base-13-125k/resolve/main/config.json',
    'facebook/xmod-base-30-125k': 'https://huggingface.co/facebook/xmod-base-30-125k/resolve/main/config.json',
    'facebook/xmod-base-30-195k': 'https://huggingface.co/facebook/xmod-base-30-195k/resolve/main/config.json',
    'facebook/xmod-base-60-125k': 'https://huggingface.co/facebook/xmod-base-60-125k/resolve/main/config.json',
    'facebook/xmod-base-60-265k': 'https://huggingface.co/facebook/xmod-base-60-265k/resolve/main/config.json',
    'facebook/xmod-base-75-125k': 'https://huggingface.co/facebook/xmod-base-75-125k/resolve/main/config.json',
    'facebook/xmod-base-75-269k': 'https://huggingface.co/facebook/xmod-base-75-269k/resolve/main/config.json',
}


class 							_UpperCAmelCase    (		snake_case      ):
    __lowerCamelCase: Optional[int]									=     'xmod'




    def __init__(      self	:							Optional[Any]	,  a	:							str=3_0_5_2_2	,  a	:							Dict=7_6_8	,  a	:							Any=1_2	,  a	:							List[str]=1_2	,  a	:							str=3_0_7_2	,  a	:							Tuple="gelu"	,  a	:							int=0.1	,  a	:							Union[str, Any]=0.1	,  a	:							str=5_1_2	,  a	:							Any=2	,  a	:							Optional[int]=0.02	,  a	:							str=1e-12	,  a	:							List[Any]=1	,  a	:							Dict=0	,  a	:							Tuple=2	,  a	:							Union[str, Any]="absolute"	,  a	:							List[str]=True	,  a	:							Optional[int]=None	,  a	:							List[Any]=False	,  a	:							List[str]=2	,  a	:							Tuple=False	,  a	:							Tuple=True	,  a	:							List[str]=True	,  a	:							Any=("en_XX",)	,  a	:							Optional[Any]=None	,  **a	:							int	,  ):






       '''simple docstring'''






       super().__init__(pad_token_id=a	,  bos_token_id=a	,  eos_token_id=a	,  **a      )

       lowercase_						:     List[str]							     =  vocab_size
       lowercase_						:     List[Any]							     =  hidden_size
       lowercase_						:     Dict							     =  num_hidden_layers
       lowercase_						:     int							     =  num_attention_heads
       lowercase_						:     Optional[int]							     =  hidden_act
       lowercase_						:     List[Any]							     =  intermediate_size
       lowercase_						:     List[str]							     =  hidden_dropout_prob
       lowercase_						:     int							     =  attention_probs_dropout_prob
       lowercase_						:     List[Any]							     =  max_position_embeddings
       lowercase_						:     str							     =  type_vocab_size
       lowercase_						:     Optional[Any]							     =  initializer_range
       lowercase_						:     Dict							     =  layer_norm_eps
       lowercase_						:     str							     =  position_embedding_type
       lowercase_						:     List[str]							     =  use_cache
       lowercase_						:     List[str]							     =  classifier_dropout
       lowercase_						:     List[Any]							     =  pre_norm
       lowercase_						:     List[str]							     =  adapter_reduction_factor
       lowercase_						:     Dict							     =  adapter_layer_norm
       lowercase_						:     Dict							     =  adapter_reuse_layer_norm
       lowercase_						:     Any							     =  ln_before_adapter
       lowercase_						:     Tuple							     =  list(a      )
       lowercase_						:     str							     =  default_language


class 							_UpperCAmelCase    (		snake_case      ):




    @property
    def 					lowerCAmelCase__					(      self	:							str      ):






       '''simple docstring'''






       if self.task == "multiple-choice":
          lowercase_						:     List[str]							     =  {0: "batch", 1: "choice", 2: "sequence"}
       else:
          lowercase_						:     Union[str, Any]							     =  {0: "batch", 1: "sequence"}
       return OrderedDict(
           [
               ("input_ids", dynamic_axis),
               ("attention_mask", dynamic_axis),
           ]      )












'''simple docstring'''
import flax.linen as nn
import jax
import jax.numpy as jnp


class 							_UpperCAmelCase    (		nn.Module      ):
    __lowerCamelCase: int
    __lowerCamelCase: jnp.dtype									=     jnp.floataa




    def 					lowerCAmelCase__					(      self	:							Optional[Any]      ):






       '''simple docstring'''






       lowercase_						:     List[Any]							     =  nn.Conv(
           self.out_channels	,  kernel_size=(3, 3)	,  strides=(1, 1)	,  padding=((1, 1), (1, 1))	,  dtype=self.dtype	,  )





    def __call__(      self	:							List[str]	,  a	:							Optional[int]      ):






       '''simple docstring'''






       lowercase_     ,		lowercase_     ,		lowercase_     ,		lowercase_						:     Optional[Any]							     =  hidden_states.shape
       lowercase_						:     Tuple							     =  jax.image.resize(
           a	,  shape=(batch, height * 2, width * 2, channels)	,  method="nearest"	,  )
       lowercase_						:     List[Any]							     =  self.conv(a      )
       return hidden_states


class 							_UpperCAmelCase    (		nn.Module      ):
    __lowerCamelCase: int
    __lowerCamelCase: jnp.dtype									=     jnp.floataa




    def 					lowerCAmelCase__					(      self	:							Optional[Any]      ):






       '''simple docstring'''






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





    def __call__(      self	:							Any	,  a	:							int      ):






       '''simple docstring'''






       lowercase_						:     Any							     =  self.conv(a      )
       return hidden_states


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




    def 					lowerCAmelCase__					(      self	:							Optional[int]      ):






       '''simple docstring'''






       lowercase_						:     Union[str, Any]							     =  self.in_channels if self.out_channels is None else self.out_channels

       lowercase_						:     Optional[int]							     =  nn.GroupNorm(num_groups=3_2	,  epsilon=1e-5      )
       lowercase_						:     Tuple							     =  nn.Conv(
           a	,  kernel_size=(3, 3)	,  strides=(1, 1)	,  padding=((1, 1), (1, 1))	,  dtype=self.dtype	,  )

       lowercase_						:     List[str]							     =  nn.Dense(a	,  dtype=self.dtype      )

       lowercase_						:     Optional[int]							     =  nn.GroupNorm(num_groups=3_2	,  epsilon=1e-5      )
       lowercase_						:     Any							     =  nn.Dropout(self.dropout_prob      )
       lowercase_						:     Dict							     =  nn.Conv(
           a	,  kernel_size=(3, 3)	,  strides=(1, 1)	,  padding=((1, 1), (1, 1))	,  dtype=self.dtype	,  )

       lowercase_						:     Tuple							     =  self.in_channels != out_channels if self.use_nin_shortcut is None else self.use_nin_shortcut

       lowercase_						:     Optional[Any]							     =  None
       if use_nin_shortcut:
          lowercase_						:     Union[str, Any]							     =  nn.Conv(
              a	,  kernel_size=(1, 1)	,  strides=(1, 1)	,  padding="VALID"	,  dtype=self.dtype	,  )





    def __call__(      self	:							List[str]	,  a	:							str	,  a	:							Dict	,  a	:							List[str]=True      ):






       '''simple docstring'''






       lowercase_						:     Dict							     =  hidden_states
       lowercase_						:     int							     =  self.norma(a      )
       lowercase_						:     List[Any]							     =  nn.swish(a      )
       lowercase_						:     Dict							     =  self.conva(a      )

       lowercase_						:     Optional[int]							     =  self.time_emb_proj(nn.swish(a      )      )
       lowercase_						:     Tuple							     =  jnp.expand_dims(jnp.expand_dims(a	,  1      )	,  1      )
       lowercase_						:     List[str]							     =  hidden_states + temb

       lowercase_						:     Optional[Any]							     =  self.norma(a      )
       lowercase_						:     Any							     =  nn.swish(a      )
       lowercase_						:     List[str]							     =  self.dropout(a	,  a      )
       lowercase_						:     int							     =  self.conva(a      )

       if self.conv_shortcut is not None:
          lowercase_						:     List[str]							     =  self.conv_shortcut(a      )

       return hidden_states + residual




