



'''simple docstring'''






import json
import os
import re
import shutil
import tempfile
import unittest
from typing import Tuple

from transformers import AddedToken, BatchEncoding, PerceiverTokenizer
from transformers.utils import cached_property, is_tf_available, is_torch_available

from ...test_tokenization_common import TokenizerTesterMixin


if is_torch_available():
     lowerCAmelCase: List[str]							=						'pt'
elif is_tf_available():
     lowerCAmelCase: Any							=						'tf'
else:
     lowerCAmelCase: str							=						'jax'

class 							a__( lowerCamelCase__		,			unittest.TestCase     ):
    lowercase__			=   PerceiverTokenizer
    lowercase__			=   False







    def       lowercase_	(				self			:  Tuple     ):
      super().setUp()
      a						: Tuple					       =					PerceiverTokenizer()
      tokenizer.save_pretrained(self.tmpdirname     )







    @cached_property
    def       lowercase_	(				self			:  Dict     ):
      return PerceiverTokenizer.from_pretrained('deepmind/language-perceiver'     )







    def       lowercase_	(				self			:  List[Any]						,      **__snake_case			:  Tuple     ):
      return self.tokenizer_class.from_pretrained(self.tmpdirname						,      **__snake_case     )







    def       lowercase_	(				self			:  Union[str, Any]						,      __snake_case			:  Optional[Any]						,      __snake_case			:  Union[str, Any]=False						,      __snake_case			:  str=20						,      __snake_case			:  List[str]=5     ):
      # XXX The default common tokenizer tests assume that every ID is decodable on its own.
      # This assumption is invalid for Perceiver because single bytes might not be
      # valid utf-8 (byte 128 for instance).
      # Here we're overriding the smallest possible method to provide
      # a clean sequence without making the same assumption.

      a						: Union[str, Any]					       =					[]
      for i in range(len(__snake_case     )     ):
        try:
          a						: int					       =					tokenizer.decode([i]						,      clean_up_tokenization_spaces=__snake_case     )
        except UnicodeDecodeError:
          pass
        toks.append((i, tok)     )

      a						: Any					       =					list(filter(lambda __snake_case     : re.match(r'^[ a-zA-Z]+$'						,      t[1]     )						,      __snake_case     )     )
      a						: Any					       =					list(filter(lambda __snake_case     : [t[0]] == tokenizer.encode(t[1]						,      add_special_tokens=__snake_case     )						,      __snake_case     )     )
      if max_length is not None and len(__snake_case     ) > max_length:
        a						: Any					       =					toks[:max_length]
      if min_length is not None and len(__snake_case     ) < min_length and len(__snake_case     ) > 0:
        while len(__snake_case     ) < min_length:
          a						: Any					       =					toks + toks
        # toks_str = [t[1] for t in toks]
      a						: str					       =					[t[0] for t in toks]

      # Ensure consistency
      a						: Tuple					       =					tokenizer.decode(__snake_case						,      clean_up_tokenization_spaces=__snake_case     )
      if " " not in output_txt and len(__snake_case     ) > 1:
        a						: List[Any]					       =					(
            tokenizer.decode([toks_ids[0]]						,      clean_up_tokenization_spaces=__snake_case     )
            + ' '
            + tokenizer.decode(toks_ids[1:]						,      clean_up_tokenization_spaces=__snake_case     )
        )
      if with_prefix_space:
        a						: List[str]					       =					' ' + output_txt
      a						: List[str]					       =					tokenizer.encode(__snake_case						,      add_special_tokens=__snake_case     )
      return output_txt, output_ids







    def       lowercase_	(				self			:  Optional[Any]     ):
      a						: str					       =					self.perceiver_tokenizer
      a						: Optional[Any]					       =					'Unicode €.'
      a						: Tuple					       =					tokenizer(__snake_case     )
      a						: Optional[int]					       =					[4, 91, 1_16, 1_11, 1_05, 1_17, 1_06, 1_07, 38, 2_32, 1_36, 1_78, 52, 5]
      self.assertEqual(encoded['input_ids']						,      __snake_case     )

      # decoding
      a						: Any					       =					tokenizer.decode(__snake_case     )
      self.assertEqual(__snake_case						,      '[CLS]Unicode €.[SEP]'     )

      a						: List[str]					       =					tokenizer('e è é ê ë'     )
      a						: Dict					       =					[4, 1_07, 38, 2_01, 1_74, 38, 2_01, 1_75, 38, 2_01, 1_76, 38, 2_01, 1_77, 5]
      self.assertEqual(encoded['input_ids']						,      __snake_case     )
      # decoding
      a						: Tuple					       =					tokenizer.decode(__snake_case     )
      self.assertEqual(__snake_case						,      '[CLS]e è é ê ë[SEP]'     )

      # encode/decode, but with `encode` instead of `__call__`
      self.assertEqual(tokenizer.decode(tokenizer.encode('e è é ê ë'     )     )						,      '[CLS]e è é ê ë[SEP]'     )







    def       lowercase_	(				self			:  str     ):
      a						: List[str]					       =					self.perceiver_tokenizer
      a						: Optional[int]					       =					['A long paragraph for summarization.', 'Another paragraph for summarization.']
      # fmt: off
      a						: Dict					       =					[4, 71, 38, 1_14, 1_17, 1_16, 1_09, 38, 1_18, 1_03, 1_20, 1_03, 1_09, 1_20, 1_03, 1_18, 1_10, 38, 1_08, 1_17, 1_20, 38, 1_21, 1_23, 1_15, 1_15, 1_03, 1_20, 1_11, 1_28, 1_03, 1_22, 1_11, 1_17, 1_16, 52, 5, 0]
      # fmt: on
      a						: Optional[int]					       =					tokenizer(__snake_case						,      padding=__snake_case						,      return_tensors=__snake_case     )
      self.assertIsInstance(__snake_case						,      __snake_case     )

      if FRAMEWORK != "jax":
        a						: Any					       =					list(batch.input_ids.numpy()[0]     )
      else:
        a						: Optional[int]					       =					list(batch.input_ids.tolist()[0]     )

      self.assertListEqual(__snake_case						,      __snake_case     )

      self.assertEqual((2, 38)						,      batch.input_ids.shape     )
      self.assertEqual((2, 38)						,      batch.attention_mask.shape     )







    def       lowercase_	(				self			:  List[str]     ):
      a						: Optional[int]					       =					self.perceiver_tokenizer
      a						: Dict					       =					['A long paragraph for summarization.', 'Another paragraph for summarization.']
      a						: str					       =					tokenizer(__snake_case						,      padding=__snake_case						,      return_tensors=__snake_case     )
      # check if input_ids are returned and no decoder_input_ids
      self.assertIn('input_ids'						,      __snake_case     )
      self.assertIn('attention_mask'						,      __snake_case     )
      self.assertNotIn('decoder_input_ids'						,      __snake_case     )
      self.assertNotIn('decoder_attention_mask'						,      __snake_case     )







    def       lowercase_	(				self			:  Optional[int]     ):
      a						: List[Any]					       =					self.perceiver_tokenizer
      a						: Union[str, Any]					       =					[
          'Summary of the text.',
          'Another summary.',
      ]
      a						: List[str]					       =					tokenizer(
          text_target=__snake_case						,      max_length=32						,      padding='max_length'						,      truncation=__snake_case						,      return_tensors=__snake_case     )
      self.assertEqual(32						,      targets['input_ids'].shape[1]     )







    def       lowercase_	(				self			:  List[Any]     ):
      # safety check on max_len default value so we are sure the test works
      a						: Union[str, Any]					       =					self.get_tokenizers()
      for tokenizer in tokenizers:
        with self.subTest(F"""{tokenizer.__class__.__name__}"""     ):
          self.assertNotEqual(tokenizer.model_max_length						,      42     )

        # Now let's start the test
      a						: List[str]					       =					self.get_tokenizers()
      for tokenizer in tokenizers:
        with self.subTest(F"""{tokenizer.__class__.__name__}"""     ):
          # Isolate this from the other tests because we save additional tokens/etc
          a						: Optional[int]					       =					tempfile.mkdtemp()

          a						: Tuple					       =					' He is very happy, UNwant\u00E9d,running'
          a						: Any					       =					tokenizer.encode(__snake_case						,      add_special_tokens=__snake_case     )
          tokenizer.save_pretrained(__snake_case     )

          a						: List[Any]					       =					tokenizer.__class__.from_pretrained(__snake_case     )
          a						: int					       =					after_tokenizer.encode(__snake_case						,      add_special_tokens=__snake_case     )
          self.assertListEqual(__snake_case						,      __snake_case     )

          shutil.rmtree(__snake_case     )

      a						: Dict					       =					self.get_tokenizers(model_max_length=42     )
      for tokenizer in tokenizers:
        with self.subTest(F"""{tokenizer.__class__.__name__}"""     ):
          # Isolate this from the other tests because we save additional tokens/etc
          a						: List[str]					       =					tempfile.mkdtemp()

          a						: int					       =					' He is very happy, UNwant\u00E9d,running'
          tokenizer.add_tokens(['bim', 'bambam']     )
          a						: List[str]					       =					tokenizer.additional_special_tokens
          additional_special_tokens.append('new_additional_special_token'     )
          tokenizer.add_special_tokens({'additional_special_tokens': additional_special_tokens}     )
          a						: Union[str, Any]					       =					tokenizer.encode(__snake_case						,      add_special_tokens=__snake_case     )
          tokenizer.save_pretrained(__snake_case     )

          a						: int					       =					tokenizer.__class__.from_pretrained(__snake_case     )
          a						: List[Any]					       =					after_tokenizer.encode(__snake_case						,      add_special_tokens=__snake_case     )
          self.assertListEqual(__snake_case						,      __snake_case     )
          self.assertIn('new_additional_special_token'						,      after_tokenizer.additional_special_tokens     )
          self.assertEqual(after_tokenizer.model_max_length						,      42     )

          a						: str					       =					tokenizer.__class__.from_pretrained(__snake_case						,      model_max_length=43     )
          self.assertEqual(tokenizer.model_max_length						,      43     )

          shutil.rmtree(__snake_case     )







    def       lowercase_	(				self			:  List[str]     ):
      a						: str					       =					[]
      if self.test_slow_tokenizer:
        tokenizer_list.append((self.tokenizer_class, self.get_tokenizer())     )

      if self.test_rust_tokenizer:
        tokenizer_list.append((self.rust_tokenizer_class, self.get_rust_tokenizer())     )

      for tokenizer_class, tokenizer_utils in tokenizer_list:
        with tempfile.TemporaryDirectory() as tmp_dir:
          tokenizer_utils.save_pretrained(__snake_case     )

          with open(os.path.join(__snake_case						,      'special_tokens_map.json'     )						,      encoding='utf-8'     ) as json_file:
            a						: Dict					       =					json.load(__snake_case     )

          with open(os.path.join(__snake_case						,      'tokenizer_config.json'     )						,      encoding='utf-8'     ) as json_file:
            a						: Union[str, Any]					       =					json.load(__snake_case     )

          a						: Dict					       =					[F"""<extra_id_{i}>""" for i in range(1_25     )]

          a						: str					       =					added_tokens_extra_ids + [
              'an_additional_special_token'
          ]
          a						: Dict					       =					added_tokens_extra_ids + [
              'an_additional_special_token'
          ]

          with open(os.path.join(__snake_case						,      'special_tokens_map.json'     )						,      'w'						,      encoding='utf-8'     ) as outfile:
            json.dump(__snake_case						,      __snake_case     )
          with open(os.path.join(__snake_case						,      'tokenizer_config.json'     )						,      'w'						,      encoding='utf-8'     ) as outfile:
            json.dump(__snake_case						,      __snake_case     )

          # the following checks allow us to verify that our test works as expected, i.e. that the tokenizer takes
          # into account the new value of additional_special_tokens given in the "tokenizer_config.json" and
          # "special_tokens_map.json" files
          a						: Tuple					       =					tokenizer_class.from_pretrained(
              __snake_case						,      )
          self.assertIn(
              'an_additional_special_token'						,      tokenizer_without_change_in_init.additional_special_tokens     )
          self.assertEqual(
              ['an_additional_special_token']						,      tokenizer_without_change_in_init.convert_ids_to_tokens(
                  tokenizer_without_change_in_init.convert_tokens_to_ids(['an_additional_special_token']     )     )						,      )

          # Now we test that we can change the value of additional_special_tokens in the from_pretrained
          a						: Dict					       =					added_tokens_extra_ids + [AddedToken('a_new_additional_special_token'						,      lstrip=__snake_case     )]
          a						: Tuple					       =					tokenizer_class.from_pretrained(
              __snake_case						,      additional_special_tokens=__snake_case						,      )

          self.assertIn('a_new_additional_special_token'						,      tokenizer.additional_special_tokens     )
          self.assertEqual(
              ['a_new_additional_special_token']						,      tokenizer.convert_ids_to_tokens(
                  tokenizer.convert_tokens_to_ids(['a_new_additional_special_token']     )     )						,      )







    def       lowercase_	(				self			:  Tuple     ):
      a						: Tuple					       =					self.perceiver_tokenizer
      self.assertEqual(tokenizer.decode([1_78]     )						,      '�'     )







    def       lowercase_	(				self			:  Union[str, Any]     ):
      pass







    def       lowercase_	(				self			:  int     ):
      pass







    def       lowercase_	(				self			:  Optional[int]     ):
      pass







    def       lowercase_	(				self			:  str     ):
      pass







    def       lowercase_	(				self			:  Optional[Any]     ):
      # The default common tokenizer tests uses invalid tokens for Perceiver that can only accept one-character
      # strings and special added tokens as tokens
      a						: str					       =					self.get_tokenizers(fast=__snake_case						,      do_lower_case=__snake_case     )
      for tokenizer in tokenizers:
        with self.subTest(F"""{tokenizer.__class__.__name__}"""     ):
          a						: Optional[Any]					       =					['[CLS]', 't', 'h', 'i', 's', ' ', 'i', 's', ' ', 'a', ' ', 't', 'e', 's', 't', '[SEP]']
          a						: Tuple					       =					tokenizer.convert_tokens_to_string(__snake_case     )

          self.assertIsInstance(__snake_case						,      __snake_case     )




'''simple docstring'''






from typing import Optional, Tuple, Union

import flax
import flax.linen as nn
import jax
import jax.numpy as jnp
from flax.core.frozen_dict import FrozenDict

from ..configuration_utils import ConfigMixin, flax_register_to_config
from ..utils import BaseOutput
from .embeddings_flax import FlaxTimestepEmbedding, FlaxTimesteps
from .modeling_flax_utils import FlaxModelMixin
from .unet_ad_blocks_flax import (
    FlaxCrossAttnDownBlockaD,
    FlaxCrossAttnUpBlockaD,
    FlaxDownBlockaD,
    FlaxUNetMidBlockaDCrossAttn,
    FlaxUpBlockaD,
)

@flax.struct.dataclass
class 							a__( lowerCamelCase__     ):
    lowercase__			=   42

@flax_register_to_config
class 							a__( nn.Module		,			lowerCamelCase__		,			lowerCamelCase__     ):
    lowercase__			=   32
    lowercase__			=   4
    lowercase__			=   4
    lowercase__			=   (
        "CrossAttnDownBlock2D",
        "CrossAttnDownBlock2D",
        "CrossAttnDownBlock2D",
        "DownBlock2D",
    )
    lowercase__			=   ("UpBlock2D", "CrossAttnUpBlock2D", "CrossAttnUpBlock2D", "CrossAttnUpBlock2D")
    lowercase__			=   False
    lowercase__			=   (3_20, 6_40, 12_80, 12_80)
    lowercase__			=   2
    lowercase__			=   8
    lowercase__			=   None
    lowercase__			=   12_80
    lowercase__			=   0.0
    lowercase__			=   False
    lowercase__			=   jnp.floataa
    lowercase__			=   True
    lowercase__			=   0
    lowercase__			=   False







    def       lowercase_	(				self			:  List[Any]						,      __snake_case			:  jax.random.KeyArray     ):
      # init input tensors
      a						: Dict					       =					(1, self.in_channels, self.sample_size, self.sample_size)
      a						: str					       =					jnp.zeros(__snake_case						,      dtype=jnp.floataa     )
      a						: Union[str, Any]					       =					jnp.ones((1,)						,      dtype=jnp.intaa     )
      a						: List[Any]					       =					jnp.zeros((1, 1, self.cross_attention_dim)						,      dtype=jnp.floataa     )

      a       ,     a						: Optional[int]					       =					jax.random.split(__snake_case     )
      a						: Any					       =					{'params': params_rng, 'dropout': dropout_rng}

      return self.init(__snake_case						,      __snake_case						,      __snake_case						,      __snake_case     )["params"]







    def       lowercase_	(				self			:  Union[str, Any]     ):
      a						: int					       =					self.block_out_channels
      a						: Tuple					       =					block_out_channels[0] * 4

      if self.num_attention_heads is not None:
        raise ValueError(
            'At the moment it is not possible to define the number of attention heads via `num_attention_heads` because of a naming issue as described in https://github.com/huggingface/diffusers/issues/2011#issuecomment-1547958131. Passing `num_attention_heads` will only be supported in diffusers v0.19.'     )

      # If `num_attention_heads` is not defined (which is the case for most models)
      # it will default to `attention_head_dim`. This looks weird upon first reading it and it is.
      # The reason for this behavior is to correct for incorrectly named variables that were introduced
      # when this library was created. The incorrect naming was only discovered much later in https://github.com/huggingface/diffusers/issues/2011#issuecomment-1547958131
      # Changing `attention_head_dim` to `num_attention_heads` for 40,000+ configurations is too backwards breaking
      # which is why we correct for the naming here.
      a						: str					       =					self.num_attention_heads or self.attention_head_dim

      # input
      a						: List[Any]					       =					nn.Conv(
          block_out_channels[0]						,      kernel_size=(3, 3)						,      strides=(1, 1)						,      padding=((1, 1), (1, 1))						,      dtype=self.dtype						,      )

      # time
      a						: List[str]					       =					FlaxTimesteps(
          block_out_channels[0]						,      flip_sin_to_cos=self.flip_sin_to_cos						,      freq_shift=self.config.freq_shift     )
      a						: Optional[int]					       =					FlaxTimestepEmbedding(__snake_case						,      dtype=self.dtype     )

      a						: Optional[Any]					       =					self.only_cross_attention
      if isinstance(__snake_case						,      __snake_case     ):
        a						: int					       =					(only_cross_attention,) * len(self.down_block_types     )

      if isinstance(__snake_case						,      __snake_case     ):
        a						: str					       =					(num_attention_heads,) * len(self.down_block_types     )

      # down
      a						: int					       =					[]
      a						: Dict					       =					block_out_channels[0]
      for i, down_block_type in enumerate(self.down_block_types     ):
        a						: List[Any]					       =					output_channel
        a						: Dict					       =					block_out_channels[i]
        a						: Union[str, Any]					       =					i == len(__snake_case     ) - 1

        if down_block_type == "CrossAttnDownBlock2D":
          a						: Dict					       =					FlaxCrossAttnDownBlockaD(
              in_channels=__snake_case						,      out_channels=__snake_case						,      dropout=self.dropout						,      num_layers=self.layers_per_block						,      num_attention_heads=num_attention_heads[i]						,      add_downsample=not is_final_block						,      use_linear_projection=self.use_linear_projection						,      only_cross_attention=only_cross_attention[i]						,      use_memory_efficient_attention=self.use_memory_efficient_attention						,      dtype=self.dtype						,      )
        else:
          a						: List[str]					       =					FlaxDownBlockaD(
              in_channels=__snake_case						,      out_channels=__snake_case						,      dropout=self.dropout						,      num_layers=self.layers_per_block						,      add_downsample=not is_final_block						,      dtype=self.dtype						,      )

        down_blocks.append(__snake_case     )
      a						: Dict					       =					down_blocks

      # mid
      a						: Union[str, Any]					       =					FlaxUNetMidBlockaDCrossAttn(
          in_channels=block_out_channels[-1]						,      dropout=self.dropout						,      num_attention_heads=num_attention_heads[-1]						,      use_linear_projection=self.use_linear_projection						,      use_memory_efficient_attention=self.use_memory_efficient_attention						,      dtype=self.dtype						,      )

      # up
      a						: List[Any]					       =					[]
      a						: Dict					       =					list(reversed(__snake_case     )     )
      a						: List[str]					       =					list(reversed(__snake_case     )     )
      a						: List[str]					       =					list(reversed(__snake_case     )     )
      a						: Optional[int]					       =					reversed_block_out_channels[0]
      for i, up_block_type in enumerate(self.up_block_types     ):
        a						: Dict					       =					output_channel
        a						: Dict					       =					reversed_block_out_channels[i]
        a						: Dict					       =					reversed_block_out_channels[min(i + 1						,      len(__snake_case     ) - 1     )]

        a						: List[Any]					       =					i == len(__snake_case     ) - 1

        if up_block_type == "CrossAttnUpBlock2D":
          a						: List[Any]					       =					FlaxCrossAttnUpBlockaD(
              in_channels=__snake_case						,      out_channels=__snake_case						,      prev_output_channel=__snake_case						,      num_layers=self.layers_per_block + 1						,      num_attention_heads=reversed_num_attention_heads[i]						,      add_upsample=not is_final_block						,      dropout=self.dropout						,      use_linear_projection=self.use_linear_projection						,      only_cross_attention=only_cross_attention[i]						,      use_memory_efficient_attention=self.use_memory_efficient_attention						,      dtype=self.dtype						,      )
        else:
          a						: Dict					       =					FlaxUpBlockaD(
              in_channels=__snake_case						,      out_channels=__snake_case						,      prev_output_channel=__snake_case						,      num_layers=self.layers_per_block + 1						,      add_upsample=not is_final_block						,      dropout=self.dropout						,      dtype=self.dtype						,      )

        up_blocks.append(__snake_case     )
        a						: Dict					       =					output_channel
      a						: int					       =					up_blocks

      # out
      a						: int					       =					nn.GroupNorm(num_groups=32						,      epsilon=1e-5     )
      a						: Any					       =					nn.Conv(
          self.out_channels						,      kernel_size=(3, 3)						,      strides=(1, 1)						,      padding=((1, 1), (1, 1))						,      dtype=self.dtype						,      )







    def __call__(				self			:  Optional[Any]						,      __snake_case			:  Dict						,      __snake_case			:  List[str]						,      __snake_case			:  Tuple						,      __snake_case			:  Dict=None						,      __snake_case			:  Any=None						,      __snake_case			:  bool = True						,      __snake_case			:  bool = False						,      ):
      # 1. time
      if not isinstance(__snake_case						,      jnp.ndarray     ):
        a						: Tuple					       =					jnp.array([timesteps]						,      dtype=jnp.intaa     )
      elif isinstance(__snake_case						,      jnp.ndarray     ) and len(timesteps.shape     ) == 0:
        a						: Tuple					       =					timesteps.astype(dtype=jnp.floataa     )
        a						: Optional[int]					       =					jnp.expand_dims(__snake_case						,      0     )

      a						: Optional[Any]					       =					self.time_proj(__snake_case     )
      a						: Optional[int]					       =					self.time_embedding(__snake_case     )

      # 2. pre-process
      a						: str					       =					jnp.transpose(__snake_case						,      (0, 2, 3, 1)     )
      a						: Optional[int]					       =					self.conv_in(__snake_case     )

      # 3. down
      a						: Optional[Any]					       =					(sample,)
      for down_block in self.down_blocks:
        if isinstance(__snake_case						,      __snake_case     ):
          a       ,     a						: Any					       =					down_block(__snake_case						,      __snake_case						,      __snake_case						,      deterministic=not train     )
        else:
          a       ,     a						: Optional[Any]					       =					down_block(__snake_case						,      __snake_case						,      deterministic=not train     )
        down_block_res_samples += res_samples

      if down_block_additional_residuals is not None:
        a						: Tuple					       =					()

        for down_block_res_sample, down_block_additional_residual in zip(
            __snake_case						,      __snake_case     ):
          down_block_res_sample += down_block_additional_residual
          new_down_block_res_samples += (down_block_res_sample,)

        a						: Tuple					       =					new_down_block_res_samples

      # 4. mid
      a						: int					       =					self.mid_block(__snake_case						,      __snake_case						,      __snake_case						,      deterministic=not train     )

      if mid_block_additional_residual is not None:
        sample += mid_block_additional_residual

      # 5. up
      for up_block in self.up_blocks:
        a						: int					       =					down_block_res_samples[-(self.layers_per_block + 1) :]
        a						: List[Any]					       =					down_block_res_samples[: -(self.layers_per_block + 1)]
        if isinstance(__snake_case						,      __snake_case     ):
          a						: Optional[int]					       =					up_block(
              __snake_case						,      temb=__snake_case						,      encoder_hidden_states=__snake_case						,      res_hidden_states_tuple=__snake_case						,      deterministic=not train						,      )
        else:
          a						: Optional[Any]					       =					up_block(__snake_case						,      temb=__snake_case						,      res_hidden_states_tuple=__snake_case						,      deterministic=not train     )

        # 6. post-process
      a						: Any					       =					self.conv_norm_out(__snake_case     )
      a						: List[str]					       =					nn.silu(__snake_case     )
      a						: Optional[int]					       =					self.conv_out(__snake_case     )
      a						: Any					       =					jnp.transpose(__snake_case						,      (0, 3, 1, 2)     )

      if not return_dict:
        return (sample,)

      return FlaxUNetaDConditionOutput(sample=__snake_case     )