"""simple docstring"""




import collections
import json
import os
import re
from typing import TYPE_CHECKING, List, Optional, Tuple

import numpy as np

from ...tokenization_utils_fast import PreTrainedTokenizer
from ...utils import logging


if TYPE_CHECKING:
				from transformers.pipelines.conversational import Conversation


__lowerCamelCase							 =     logging.get_logger(__name__)

__lowerCamelCase							 =     {"vocab_file": "vocab.txt", "emoji_file": "emoji.json"}

__lowerCamelCase							 =     {
    "vocab_file": {
        "abeja/gpt-neox-japanese-2.7b": "https://huggingface.co/abeja/gpt-neox-japanese-2.7b/resolve/main/vocab.txt",
    },
    "emoji_file": {
        "abeja/gpt-neox-japanese-2.7b": "https://huggingface.co/abeja/gpt-neox-japanese-2.7b/resolve/main/emoji.json",
    },
}

__lowerCamelCase							 =     {
    "abeja/gpt-neox-japanese-2.7b": 20_48,
}






def      UpperCAmelCase    (		UpperCamelCase__				,			UpperCamelCase__ ):






							"""simple docstring"""





							with open(SCREAMING_SNAKE_CASE__				,			'r'				,			encoding='utf-8' ) as f:
														A__		   =							json.loads(f.read() )

							A__		   =							collections.OrderedDict()
							A__		   =							collections.OrderedDict()
							A__		   =							collections.OrderedDict()
							with open(SCREAMING_SNAKE_CASE__				,			'r'				,			encoding='utf-8' ) as f:
														A__		   =							f.readlines()
							A__		   =							[[t.rstrip('\n' )] if (t == ',' or ',' not in t) else t.rstrip('\n' ).split(',' ) for t in token]
							for idx, b in enumerate(SCREAMING_SNAKE_CASE__ ):
														A__		   =							b
														A__		   =							idx
														for wd in b:
																					A__		   =							idx

							return vocab, raw_vocab, ids_to_tokens, emoji
class 			UpperCamelCase__(	UpperCamelCase_       ):
						lowerCAmelCase__     :  Tuple  							=						VOCAB_FILES_NAMES
						lowerCAmelCase__     :  Tuple  							=						PRETRAINED_VOCAB_FILES_MAP
						lowerCAmelCase__     :  Union[str, Any]  							=						PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
						lowerCAmelCase__     :  List[Any]  							=						['input_ids', 'attention_mask']





						def __init__(				self						,__UpperCAmelCase						,__UpperCAmelCase						,__UpperCAmelCase="<|endoftext|>"						,__UpperCAmelCase="<|endoftext|>"						,__UpperCAmelCase="<|startoftext|>"						,__UpperCAmelCase="<|endoftext|>"						,__UpperCAmelCase=False						,**__UpperCAmelCase						,)    -> Union[str, Any]:
													super().__init__(
													    unk_token=lowercase_						,pad_token=lowercase_						,bos_token=lowercase_						,eos_token=lowercase_						,do_clean_text=lowercase_						,**lowercase_						,)
													if not os.path.isfile(lowercase_   ):
																				raise ValueError(
																				    f'''Can\'t find a vocabulary file at path \'{vocab_file}\'. To load the vocabulary from a Google pretrained'''
																				    ' model use `tokenizer = GPTNeoXJapaneseokenizer.from_pretrained(PRETRAINED_MODEL_NAME)`'   )
													if not os.path.isfile(lowercase_   ):
																				raise ValueError(
																				    f'''Can\'t find a emoji file at path \'{emoji_file}\'. To load the emoji information from a Google'''
																				    ' pretrained model use `tokenizer = GPTNeoXJapaneseokenizer.from_pretrained(PRETRAINED_MODEL_NAME)`'   )
													A__		   =							do_clean_text
													A__		   =							load_vocab_and_emoji(lowercase_						,lowercase_   )
													A__		   =							SubWordJapaneseTokenizer(
													    vocab=self.vocab						,ids_to_tokens=self.ids_to_tokens						,emoji=self.emoji   )





						@property
						def  snake_case__		(				self   )    -> Optional[Any]:
													return len(self.raw_vocab   )





						def  snake_case__		(				self   )    -> Dict:
													return dict(self.raw_vocab						,**self.added_tokens_encoder   )





						def  snake_case__		(				self						,__UpperCAmelCase   )    -> str:
													return self.subword_tokenizer.tokenize(lowercase_						,clean=self.do_clean_text   )





						def  snake_case__		(				self						,__UpperCAmelCase   )    -> Tuple:
													return self.vocab.get(lowercase_						,self.vocab.get(self.unk_token   )   )





						def  snake_case__		(				self						,__UpperCAmelCase   )    -> Any:
													return self.subword_tokenizer.convert_id_to_token(lowercase_   )





						def  snake_case__		(				self						,__UpperCAmelCase   )    -> int:
													A__		   =							''.join(lowercase_   ).strip()
													return out_string





						def  snake_case__		(				self						,__UpperCAmelCase   )    -> List[int]:
													A__		   =							[]
													for is_user, text in conversation.iter_texts():
																				input_ids.extend(self.encode(lowercase_						,add_special_tokens=lowercase_   ) + [self.eos_token_id]   )

													if len(lowercase_   ) > self.model_max_length:
																				A__		   =							input_ids[-self.model_max_length :]
													return input_ids





						def  snake_case__		(				self						,__UpperCAmelCase						,__UpperCAmelCase = None   )    -> Tuple[str]:
													A__		   =							0
													if os.path.isdir(lowercase_   ):
																				A__		   =							os.path.join(
																				    lowercase_						,(filename_prefix + '-' if filename_prefix else '') + VOCAB_FILES_NAMES['vocab_file']   )
																				A__		   =							os.path.join(
																				    lowercase_						,(filename_prefix + '-' if filename_prefix else '') + VOCAB_FILES_NAMES['emoji_file']   )
													else:
																				A__		   =							(
																				    (filename_prefix + '-' if filename_prefix else '') + save_directory + VOCAB_FILES_NAMES['vocab_file']
																				)
																				A__		   =							(
																				    (filename_prefix + '-' if filename_prefix else '') + save_directory + VOCAB_FILES_NAMES['emoji_file']
																				)
													with open(lowercase_						,'w'						,encoding='utf-8'   ) as writer:
																				for token_index, token in self.ids_to_tokens.items():
																											if index != token_index:
																																		logger.warning(
																																		    f'''Saving vocabulary to {vocab_file}: vocabulary indices are not consecutive.'''
																																		    ' Please check that the vocabulary is not corrupted!'   )
																																		A__		   =							token_index
																											writer.write(','.join(lowercase_   ) + '\n'   )
																											index += 1
													with open(lowercase_						,'w'						,encoding='utf-8'   ) as writer:
																				json.dump(self.emoji						,lowercase_   )
													return vocab_file, emoji_file






class 			UpperCamelCase__(	UpperCamelCase_       ):





						def __init__(				self						,__UpperCAmelCase						,__UpperCAmelCase						,__UpperCAmelCase   )    -> Union[str, Any]:
													A__		   =							vocab  # same as swe
													A__		   =							ids_to_tokens  # same as bpe
													A__		   =							emoji
													A__		   =							np.max([len(lowercase_   ) for w in self.vocab.keys()]   )
													A__		   =							re.compile(R'(https?|ftp)(:\/\/[-_\.!~*\'()a-zA-Z0-9;\/?:\@&=\+$,%#]+)'   )
													A__		   =							re.compile(R'[A-Za-z0-9\._+]*@[\-_0-9A-Za-z]+(\.[A-Za-z]+)*'   )
													A__		   =							re.compile(R'[\(]{0,1}[0-9]{2,4}[\)\-\(]{0,1}[0-9]{2,4}[\)\-]{0,1}[0-9]{3,4}'   )
													A__		   =							re.compile(
													    R'([12]\d{3}[/\-年])*(0?[1-9]|1[0-2])[/\-月]((0?[1-9]|[12][0-9]|3[01])日?)*(\d{1,2}|:|\d{1,2}時|\d{1,2}分|\(日\)|\(月\)|\(火\)|\(水\)|\(木\)|\(金\)|\(土\)|㈰|㈪|㈫|㈬|㈭|㈮|㈯)*'   )
													A__		   =							re.compile(
													    R'(明治|大正|昭和|平成|令和|㍾|㍽|㍼|㍻|\u32ff)\d{1,2}年(0?[1-9]|1[0-2])月(0?[1-9]|[12][0-9]|3[01])日(\d{1,2}|:|\d{1,2}時|\d{1,2}分|\(日\)|\(月\)|\(火\)|\(水\)|\(木\)|\(金\)|\(土\)|㈰|㈪|㈫|㈬|㈭|㈮|㈯)*'   )
													A__		   =							re.compile(
													    R'((0|[1-9]\d*|[1-9]\d{0,2}(,\d{3})+)*億)*((0|[1-9]\d*|[1-9]\d{0,2}(,\d{3})+)*万)*((0|[1-9]\d*|[1-9]\d{0,2}(,\d{3})+)*千)*(0|[1-9]\d*|[1-9]\d{0,2}(,\d{3})+)*(千円|万円|千万円|円|千ドル|万ドル|千万ドル|ドル|千ユーロ|万ユーロ|千万ユーロ|ユーロ)+(\(税込\)|\(税抜\)|\+tax)*'   )
													A__		   =							'─━│┃┄┅┆┇┈┉┊┋┌┍┎┏┐┑┒┓└┕┖┗┘┙┚┛├┝┞┟┠┡┢┣┤┥┦┧┨┩┪┫┬┭┮┯┰┱┲┳┴┵┶┷┸┹┺┻┼┽┾┿╀╁╂╃╄╅╆╇╈╉╊╋╌╍╎╏═║╒╓╔╕╖╗╘╙╚╛╜╝╞╟╠╡╢╣╤╥╦╧╨╩╪╫╬╭╮╯╰╱╲╳╴╵╶╷╸╹╺╻╼╽╾╿'
													A__		   =							'▀▁▂▃▄▅▆▇█▉▊▋▌▍▎▏▐░▒▓▔▕▖▗▘▙▚▛▜▝▞▟'
													A__		   =							str.maketrans({k: '<BLOCK>' for k in keisen + blocks}   )





						def __len__(				self   )    -> str:
													return len(self.ids_to_tokens   )





						def  snake_case__		(				self						,__UpperCAmelCase   )    -> Union[str, Any]:
													A__		   =							self.content_repattera.sub('<URL>'						,lowercase_   )
													A__		   =							self.content_repattera.sub('<EMAIL>'						,lowercase_   )
													A__		   =							self.content_repattera.sub('<TEL>'						,lowercase_   )
													A__		   =							self.content_repattera.sub('<DATE>'						,lowercase_   )
													A__		   =							self.content_repattera.sub('<DATE>'						,lowercase_   )
													A__		   =							self.content_repattera.sub('<PRICE>'						,lowercase_   )
													A__		   =							content.translate(self.content_transa   )
													while "<BLOCK><BLOCK>" in content:
																				A__		   =							content.replace('<BLOCK><BLOCK>'						,'<BLOCK>'   )
													return content





						def  snake_case__		(				self						,__UpperCAmelCase						,__UpperCAmelCase=False   )    -> Tuple:
													A__		   =							text.replace(' '						,'<SP>'   )
													A__		   =							text.replace('　'						,'<SP>'   )
													A__		   =							text.replace('\r\n'						,'<BR>'   )
													A__		   =							text.replace('\n'						,'<BR>'   )
													A__		   =							text.replace('\r'						,'<BR>'   )
													A__		   =							text.replace('\t'						,'<TAB>'   )
													A__		   =							text.replace('—'						,'ー'   )
													A__		   =							text.replace('−'						,'ー'   )
													for k, v in self.emoji["emoji"].items():
																				if k in text:
																											A__		   =							text.replace(lowercase_						,lowercase_   )
													if clean:
																				A__		   =							self.clean_text(lowercase_   )

													def check_simbol(__UpperCAmelCase   ):
																				A__		   =							x.encode()
																				if len(lowercase_   ) == 1 and len(lowercase_   ) == 2:
																											A__		   =							(int(e[0]   ) << 8) + int(e[1]   )
																											if (
																											    (c >= 0XC_2A1 and c <= 0XC_2BF)
																											    or (c >= 0XC_780 and c <= 0XC_783)
																											    or (c >= 0XC_AB9 and c <= 0XC_BBF)
																											    or (c >= 0XC_C80 and c <= 0XC_DA2)
																											):
																																		return True
																				return False

													def checkuae(__UpperCAmelCase   ):
																				A__		   =							x.encode()
																				if len(lowercase_   ) == 1 and len(lowercase_   ) == 3:
																											A__		   =							(int(e[0]   ) << 16) + (int(e[1]   ) << 8) + int(e[2]   )
																											if c >= 0XE28_080 and c <= 0XE2B_07F:
																																		return True
																				return False

													A__		   =							0
													A__		   =							[]
													while pos < len(lowercase_   ):
																				A__		   =							min(len(lowercase_   )						,pos + self.maxlen + 1   ) if text[pos] == '<' else pos + 3
																				A__		   =							[]  # (token_id, token, pos)
																				for e in range(lowercase_						,lowercase_						,-1   ):
																											A__		   =							text[pos:e]
																											if wd in self.vocab:
																																		if wd[0] == "<" and len(lowercase_   ) > 2:
																																									A__		   =							[(self.vocab[wd], wd, e)]
																																									break
																																		else:
																																									candidates.append((self.vocab[wd], wd, e)   )
																				if len(lowercase_   ) > 0:
																											# the smallest token_id is adopted
																											A__		   =							sorted(lowercase_						,key=lambda __UpperCAmelCase   : x[0]   )[0]
																											result.append(lowercase_   )
																											A__		   =							e
																				else:
																											A__		   =							pos + 1
																											A__		   =							text[pos:end]
																											if check_simbol(lowercase_   ):
																																		result.append('<KIGOU>'   )
																											elif checkuae(lowercase_   ):
																																		result.append('<U2000U2BFF>'   )
																											else:
																																		for i in wd.encode('utf-8'   ):
																																									result.append('<|byte%d|>' % i   )
																											A__		   =							end
													return result





						def  snake_case__		(				self						,__UpperCAmelCase						,__UpperCAmelCase="\n"   )    -> int:
													A__		   =							[]
													A__		   =							[]
													A__		   =							self.ids_to_tokens[index][0]
													if word[:6] == "<|byte" and word[-2:] == "|>":
																				byte_tokens.append(int(word[6:-2]   )   )
													else:
																				if len(lowercase_   ) > 0:
																											words.append(bytearray(lowercase_   ).decode('utf-8'						,errors='replace'   )   )
																											A__		   =							[]
																				if word[:7] == "<|emoji" and word[-2:] == "|>":
																											words.append(self.emoji['emoji_inv'][word]   )
																				elif word == "<SP>":
																											words.append(' '   )
																				elif word == "<BR>":
																											words.append(lowercase_   )
																				elif word == "<TAB>":
																											words.append('\t'   )
																				elif word == "<BLOCK>":
																											words.append('▀'   )
																				elif word == "<KIGOU>":
																											words.append('ǀ'   )
																				elif word == "<U2000U2BFF>":
																											words.append('‖'   )
																				else:
																											words.append(lowercase_   )
													if len(lowercase_   ) > 0:
																				words.append(bytearray(lowercase_   ).decode('utf-8'						,errors='replace'   )   )
													A__		   =							''.join(lowercase_   )
													return text









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

from .attention_flax import FlaxTransformeraDModel
from .resnet_flax import FlaxDownsampleaD, FlaxResnetBlockaD, FlaxUpsampleaD




class A  (   nn.Module     ):
      UpperCamelCase__							:  int
      UpperCamelCase__							:  int
      UpperCamelCase__							:  float      =0.0
      UpperCamelCase__							:  int      =1
      UpperCamelCase__							:  int      =1
      UpperCamelCase__							:  bool      =True
      UpperCamelCase__							:  bool      =False
      UpperCamelCase__							:  bool      =False
      UpperCamelCase__							:  bool      =False
      UpperCamelCase__							:  jnp.dtype      =jnp.floataa






      def        lowerCamelCase       (					self						:     Any )					->						Any:
             """simple docstring"""




             _lowerCamelCase       :		str		=[]
             _lowerCamelCase       :		Dict		=[]

             for i in range(self.num_layers ):
                    _lowerCamelCase       :		Union[str, Any]		=self.in_channels if i == 0 else self.out_channels

                    _lowerCamelCase       :		Any		=FlaxResnetBlockaD(
                        in_channels=lowercase_			,   out_channels=self.out_channels			,   dropout_prob=self.dropout			,   dtype=self.dtype			,   )
                    resnets.append(lowercase_ )

                    _lowerCamelCase       :		Dict		=FlaxTransformeraDModel(
                        in_channels=self.out_channels			,   n_heads=self.num_attention_heads			,   d_head=self.out_channels // self.num_attention_heads			,   depth=1			,   use_linear_projection=self.use_linear_projection			,   only_cross_attention=self.only_cross_attention			,   use_memory_efficient_attention=self.use_memory_efficient_attention			,   dtype=self.dtype			,   )
                    attentions.append(lowercase_ )

             _lowerCamelCase       :		Optional[int]		=resnets
             _lowerCamelCase       :		Dict		=attentions

             if self.add_downsample:
                    _lowerCamelCase       :		Union[str, Any]		=FlaxDownsampleaD(self.out_channels			,   dtype=self.dtype )






      def __call__(					self						:     Any			,   lowercase_						:     Optional[Any]			,   lowercase_						:     List[Any]			,   lowercase_						:     Union[str, Any]			,   lowercase_						:     List[str]=True )					->						Union[str, Any]:
             """simple docstring"""




             _lowerCamelCase       :		Tuple		=()

             for resnet, attn in zip(self.resnets			,   self.attentions ):
                    _lowerCamelCase       :		Union[str, Any]		=resnet(lowercase_			,   lowercase_			,   deterministic=lowercase_ )
                    _lowerCamelCase       :		Union[str, Any]		=attn(lowercase_			,   lowercase_			,   deterministic=lowercase_ )
                    output_states += (hidden_states,)

             if self.add_downsample:
                    _lowerCamelCase       :		Optional[int]		=self.downsamplers_a(lowercase_ )
                    output_states += (hidden_states,)

             return hidden_states, output_states




class A  (   nn.Module     ):
      UpperCamelCase__							:  int
      UpperCamelCase__							:  int
      UpperCamelCase__							:  float      =0.0
      UpperCamelCase__							:  int      =1
      UpperCamelCase__							:  bool      =True
      UpperCamelCase__							:  jnp.dtype      =jnp.floataa






      def        lowerCamelCase       (					self						:     Optional[int] )					->						int:
             """simple docstring"""




             _lowerCamelCase       :		str		=[]

             for i in range(self.num_layers ):
                    _lowerCamelCase       :		Tuple		=self.in_channels if i == 0 else self.out_channels

                    _lowerCamelCase       :		Any		=FlaxResnetBlockaD(
                        in_channels=lowercase_			,   out_channels=self.out_channels			,   dropout_prob=self.dropout			,   dtype=self.dtype			,   )
                    resnets.append(lowercase_ )
             _lowerCamelCase       :		Union[str, Any]		=resnets

             if self.add_downsample:
                    _lowerCamelCase       :		List[str]		=FlaxDownsampleaD(self.out_channels			,   dtype=self.dtype )






      def __call__(					self						:     Any			,   lowercase_						:     Dict			,   lowercase_						:     Union[str, Any]			,   lowercase_						:     Optional[Any]=True )					->						Dict:
             """simple docstring"""




             _lowerCamelCase       :		Optional[int]		=()

             for resnet in self.resnets:
                    _lowerCamelCase       :		Tuple		=resnet(lowercase_			,   lowercase_			,   deterministic=lowercase_ )
                    output_states += (hidden_states,)

             if self.add_downsample:
                    _lowerCamelCase       :		Tuple		=self.downsamplers_a(lowercase_ )
                    output_states += (hidden_states,)

             return hidden_states, output_states




class A  (   nn.Module     ):
      UpperCamelCase__							:  int
      UpperCamelCase__							:  int
      UpperCamelCase__							:  int
      UpperCamelCase__							:  float      =0.0
      UpperCamelCase__							:  int      =1
      UpperCamelCase__							:  int      =1
      UpperCamelCase__							:  bool      =True
      UpperCamelCase__							:  bool      =False
      UpperCamelCase__							:  bool      =False
      UpperCamelCase__							:  bool      =False
      UpperCamelCase__							:  jnp.dtype      =jnp.floataa






      def        lowerCamelCase       (					self						:     Dict )					->						Tuple:
             """simple docstring"""




             _lowerCamelCase       :		str		=[]
             _lowerCamelCase       :		List[str]		=[]

             for i in range(self.num_layers ):
                    _lowerCamelCase       :		List[str]		=self.in_channels if (i == self.num_layers - 1) else self.out_channels
                    _lowerCamelCase       :		Tuple		=self.prev_output_channel if i == 0 else self.out_channels

                    _lowerCamelCase       :		List[str]		=FlaxResnetBlockaD(
                        in_channels=resnet_in_channels + res_skip_channels			,   out_channels=self.out_channels			,   dropout_prob=self.dropout			,   dtype=self.dtype			,   )
                    resnets.append(lowercase_ )

                    _lowerCamelCase       :		Tuple		=FlaxTransformeraDModel(
                        in_channels=self.out_channels			,   n_heads=self.num_attention_heads			,   d_head=self.out_channels // self.num_attention_heads			,   depth=1			,   use_linear_projection=self.use_linear_projection			,   only_cross_attention=self.only_cross_attention			,   use_memory_efficient_attention=self.use_memory_efficient_attention			,   dtype=self.dtype			,   )
                    attentions.append(lowercase_ )

             _lowerCamelCase       :		int		=resnets
             _lowerCamelCase       :		Dict		=attentions

             if self.add_upsample:
                    _lowerCamelCase       :		str		=FlaxUpsampleaD(self.out_channels			,   dtype=self.dtype )






      def __call__(					self						:     Optional[Any]			,   lowercase_						:     Any			,   lowercase_						:     Any			,   lowercase_						:     List[Any]			,   lowercase_						:     Dict			,   lowercase_						:     Union[str, Any]=True )					->						Optional[int]:
             """simple docstring"""




             for resnet, attn in zip(self.resnets			,   self.attentions ):
                    # pop res hidden states
                    _lowerCamelCase       :		Optional[int]		=res_hidden_states_tuple[-1]
                    _lowerCamelCase       :		Union[str, Any]		=res_hidden_states_tuple[:-1]
                    _lowerCamelCase       :		Any		=jnp.concatenate((hidden_states, res_hidden_states)			,   axis=-1 )

                    _lowerCamelCase       :		Optional[Any]		=resnet(lowercase_			,   lowercase_			,   deterministic=lowercase_ )
                    _lowerCamelCase       :		List[Any]		=attn(lowercase_			,   lowercase_			,   deterministic=lowercase_ )

             if self.add_upsample:
                    _lowerCamelCase       :		Optional[Any]		=self.upsamplers_a(lowercase_ )

             return hidden_states




class A  (   nn.Module     ):
      UpperCamelCase__							:  int
      UpperCamelCase__							:  int
      UpperCamelCase__							:  int
      UpperCamelCase__							:  float      =0.0
      UpperCamelCase__							:  int      =1
      UpperCamelCase__							:  bool      =True
      UpperCamelCase__							:  jnp.dtype      =jnp.floataa






      def        lowerCamelCase       (					self						:     List[Any] )					->						Dict:
             """simple docstring"""




             _lowerCamelCase       :		List[str]		=[]

             for i in range(self.num_layers ):
                    _lowerCamelCase       :		Tuple		=self.in_channels if (i == self.num_layers - 1) else self.out_channels
                    _lowerCamelCase       :		int		=self.prev_output_channel if i == 0 else self.out_channels

                    _lowerCamelCase       :		str		=FlaxResnetBlockaD(
                        in_channels=resnet_in_channels + res_skip_channels			,   out_channels=self.out_channels			,   dropout_prob=self.dropout			,   dtype=self.dtype			,   )
                    resnets.append(lowercase_ )

             _lowerCamelCase       :		str		=resnets

             if self.add_upsample:
                    _lowerCamelCase       :		List[str]		=FlaxUpsampleaD(self.out_channels			,   dtype=self.dtype )






      def __call__(					self						:     List[str]			,   lowercase_						:     str			,   lowercase_						:     Dict			,   lowercase_						:     Union[str, Any]			,   lowercase_						:     Any=True )					->						int:
             """simple docstring"""




             for resnet in self.resnets:
                    # pop res hidden states
                    _lowerCamelCase       :		List[str]		=res_hidden_states_tuple[-1]
                    _lowerCamelCase       :		str		=res_hidden_states_tuple[:-1]
                    _lowerCamelCase       :		List[str]		=jnp.concatenate((hidden_states, res_hidden_states)			,   axis=-1 )

                    _lowerCamelCase       :		Optional[Any]		=resnet(lowercase_			,   lowercase_			,   deterministic=lowercase_ )

             if self.add_upsample:
                    _lowerCamelCase       :		Union[str, Any]		=self.upsamplers_a(lowercase_ )

             return hidden_states




class A  (   nn.Module     ):
      UpperCamelCase__							:  int
      UpperCamelCase__							:  float      =0.0
      UpperCamelCase__							:  int      =1
      UpperCamelCase__							:  int      =1
      UpperCamelCase__							:  bool      =False
      UpperCamelCase__							:  bool      =False
      UpperCamelCase__							:  jnp.dtype      =jnp.floataa






      def        lowerCamelCase       (					self						:     int )					->						Tuple:
             """simple docstring"""




             _lowerCamelCase       :		Optional[Any]		=[
                 FlaxResnetBlockaD(
                     in_channels=self.in_channels			,   out_channels=self.in_channels			,   dropout_prob=self.dropout			,   dtype=self.dtype			,   )
             ]

             _lowerCamelCase       :		Any		=[]

             for _ in range(self.num_layers ):
                    _lowerCamelCase       :		Optional[int]		=FlaxTransformeraDModel(
                        in_channels=self.in_channels			,   n_heads=self.num_attention_heads			,   d_head=self.in_channels // self.num_attention_heads			,   depth=1			,   use_linear_projection=self.use_linear_projection			,   use_memory_efficient_attention=self.use_memory_efficient_attention			,   dtype=self.dtype			,   )
                    attentions.append(lowercase_ )

                    _lowerCamelCase       :		Tuple		=FlaxResnetBlockaD(
                        in_channels=self.in_channels			,   out_channels=self.in_channels			,   dropout_prob=self.dropout			,   dtype=self.dtype			,   )
                    resnets.append(lowercase_ )

             _lowerCamelCase       :		List[Any]		=resnets
             _lowerCamelCase       :		List[str]		=attentions






      def __call__(					self						:     Optional[int]			,   lowercase_						:     List[Any]			,   lowercase_						:     Dict			,   lowercase_						:     Tuple			,   lowercase_						:     List[str]=True )					->						int:
             """simple docstring"""




             _lowerCamelCase       :		Dict		=self.resnets[0](lowercase_			,   lowercase_ )
             for attn, resnet in zip(self.attentions			,   self.resnets[1:] ):
                    _lowerCamelCase       :		Tuple		=attn(lowercase_			,   lowercase_			,   deterministic=lowercase_ )
                    _lowerCamelCase       :		List[str]		=resnet(lowercase_			,   lowercase_			,   deterministic=lowercase_ )

             return hidden_states


