


from __future__ import annotations

import unittest

from transformers import RoFormerConfig, is_tf_available
from transformers.testing_utils import require_tf, slow

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
    import tensorflow as tf

    from transformers import (
        TFRoFormerForCausalLM,
        TFRoFormerForMaskedLM,
        TFRoFormerForMultipleChoice,
        TFRoFormerForQuestionAnswering,
        TFRoFormerForSequenceClassification,
        TFRoFormerForTokenClassification,
        TFRoFormerModel,
    )
    from transformers.models.roformer.modeling_tf_roformer import (
        TFRoFormerSelfAttention,
        TFRoFormerSinusoidalPositionalEmbedding,
    )



class 	__lowerCamelCase			:







       def __init__(			self: Any,A_: Tuple,A_: Optional[int]=13,A_: Tuple=7,A_: List[str]=True,A_: Optional[Any]=True,A_: Optional[Any]=True,A_: List[str]=True,A_: Optional[int]=99,A_: Optional[int]=32,A_: str=2,A_: Dict=4,A_: Optional[int]=37,A_: int="gelu",A_: Tuple=0.1,A_: Any=0.1,A_: Union[str, Any]=512,A_: Union[str, Any]=16,A_: str=2,A_: str=0.0_2,A_: Optional[int]=3,A_: Any=4,A_: Tuple=None,):






            '''simple docstring'''




            __UpperCamelCase =			parent
            __UpperCamelCase =			13
            __UpperCamelCase =			7
            __UpperCamelCase =			True
            __UpperCamelCase =			True
            __UpperCamelCase =			True
            __UpperCamelCase =			True
            __UpperCamelCase =			99
            __UpperCamelCase =			32
            __UpperCamelCase =			2
            __UpperCamelCase =			4
            __UpperCamelCase =			37
            __UpperCamelCase =			'gelu'
            __UpperCamelCase =			0.1
            __UpperCamelCase =			0.1
            __UpperCamelCase =			512
            __UpperCamelCase =			16
            __UpperCamelCase =			2
            __UpperCamelCase =			0.0_2
            __UpperCamelCase =			3
            __UpperCamelCase =			4
            __UpperCamelCase =			None







       def 		snake_case_	(			self: List[str]					):






            '''simple docstring'''




            __UpperCamelCase =			ids_tensor([self.batch_size, self.seq_length],self.vocab_size					)

            __UpperCamelCase =			None
            if self.use_input_mask:
                 __UpperCamelCase =			random_attention_mask([self.batch_size, self.seq_length]					)

            __UpperCamelCase =			None
            if self.use_token_type_ids:
                 __UpperCamelCase =			ids_tensor([self.batch_size, self.seq_length],self.type_vocab_size					)

            __UpperCamelCase =			None
            __UpperCamelCase =			None
            __UpperCamelCase =			None
            if self.use_labels:
                 __UpperCamelCase =			ids_tensor([self.batch_size],self.type_sequence_label_size					)
                 __UpperCamelCase =			ids_tensor([self.batch_size, self.seq_length],self.num_labels					)
                 __UpperCamelCase =			ids_tensor([self.batch_size],self.num_choices					)

            __UpperCamelCase =			RoFormerConfig(
                vocab_size=self.vocab_size,hidden_size=self.hidden_size,num_hidden_layers=self.num_hidden_layers,num_attention_heads=self.num_attention_heads,intermediate_size=self.intermediate_size,hidden_act=self.hidden_act,hidden_dropout_prob=self.hidden_dropout_prob,attention_probs_dropout_prob=self.attention_probs_dropout_prob,max_position_embeddings=self.max_position_embeddings,type_vocab_size=self.type_vocab_size,initializer_range=self.initializer_range,return_dict=snake_case__,)

            return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels







       def 		snake_case_	(			self: str,A_: Dict,A_: int,A_: List[str],A_: Any,A_: int,A_: Optional[int],A_: Tuple					):






            '''simple docstring'''




            __UpperCamelCase =			TFRoFormerModel(config=snake_case__					)
            __UpperCamelCase =			{'input_ids': input_ids, 'attention_mask': input_mask, 'token_type_ids': token_type_ids}

            __UpperCamelCase =			[input_ids, input_mask]
            __UpperCamelCase =			model(snake_case__					)

            __UpperCamelCase =			model(snake_case__					)

            self.parent.assertEqual(result.last_hidden_state.shape,(self.batch_size, self.seq_length, self.hidden_size)					)







       def 		snake_case_	(			self: Dict,A_: Optional[Any],A_: List[str],A_: Any,A_: int,A_: str,A_: int,A_: Union[str, Any]					):






            '''simple docstring'''




            __UpperCamelCase =			True
            __UpperCamelCase =			TFRoFormerForCausalLM(config=snake_case__					)
            __UpperCamelCase =			{
                'input_ids': input_ids,
                'attention_mask': input_mask,
                'token_type_ids': token_type_ids,
            }
            __UpperCamelCase =			model(snake_case__					)['logits']
            self.parent.assertListEqual(
                list(prediction_scores.numpy().shape					),[self.batch_size, self.seq_length, self.vocab_size]					)







       def 		snake_case_	(			self: str,A_: Optional[int],A_: Any,A_: Tuple,A_: List[str],A_: Tuple,A_: Any,A_: Union[str, Any]					):






            '''simple docstring'''




            __UpperCamelCase =			TFRoFormerForMaskedLM(config=snake_case__					)
            __UpperCamelCase =			{
                'input_ids': input_ids,
                'attention_mask': input_mask,
                'token_type_ids': token_type_ids,
            }
            __UpperCamelCase =			model(snake_case__					)
            self.parent.assertEqual(result.logits.shape,(self.batch_size, self.seq_length, self.vocab_size)					)







       def 		snake_case_	(			self: Tuple,A_: Union[str, Any],A_: Dict,A_: Optional[Any],A_: Optional[Any],A_: List[str],A_: Dict,A_: Optional[Any]					):






            '''simple docstring'''




            __UpperCamelCase =			self.num_labels
            __UpperCamelCase =			TFRoFormerForSequenceClassification(config=snake_case__					)
            __UpperCamelCase =			{
                'input_ids': input_ids,
                'attention_mask': input_mask,
                'token_type_ids': token_type_ids,
            }

            __UpperCamelCase =			model(snake_case__					)
            self.parent.assertEqual(result.logits.shape,(self.batch_size, self.num_labels)					)







       def 		snake_case_	(			self: Tuple,A_: str,A_: List[str],A_: str,A_: List[Any],A_: List[str],A_: Any,A_: List[str]					):






            '''simple docstring'''




            __UpperCamelCase =			self.num_choices
            __UpperCamelCase =			TFRoFormerForMultipleChoice(config=snake_case__					)
            __UpperCamelCase =			tf.tile(tf.expand_dims(snake_case__,1					),(1, self.num_choices, 1)					)
            __UpperCamelCase =			tf.tile(tf.expand_dims(snake_case__,1					),(1, self.num_choices, 1)					)
            __UpperCamelCase =			tf.tile(tf.expand_dims(snake_case__,1					),(1, self.num_choices, 1)					)
            __UpperCamelCase =			{
                'input_ids': multiple_choice_inputs_ids,
                'attention_mask': multiple_choice_input_mask,
                'token_type_ids': multiple_choice_token_type_ids,
            }
            __UpperCamelCase =			model(snake_case__					)
            self.parent.assertEqual(result.logits.shape,(self.batch_size, self.num_choices)					)







       def 		snake_case_	(			self: Union[str, Any],A_: int,A_: Tuple,A_: Union[str, Any],A_: Optional[Any],A_: Optional[Any],A_: str,A_: int					):






            '''simple docstring'''




            __UpperCamelCase =			self.num_labels
            __UpperCamelCase =			TFRoFormerForTokenClassification(config=snake_case__					)
            __UpperCamelCase =			{
                'input_ids': input_ids,
                'attention_mask': input_mask,
                'token_type_ids': token_type_ids,
            }
            __UpperCamelCase =			model(snake_case__					)
            self.parent.assertEqual(result.logits.shape,(self.batch_size, self.seq_length, self.num_labels)					)







       def 		snake_case_	(			self: Any,A_: Any,A_: Optional[Any],A_: Optional[Any],A_: int,A_: int,A_: List[str],A_: str					):






            '''simple docstring'''




            __UpperCamelCase =			TFRoFormerForQuestionAnswering(config=snake_case__					)
            __UpperCamelCase =			{
                'input_ids': input_ids,
                'attention_mask': input_mask,
                'token_type_ids': token_type_ids,
            }

            __UpperCamelCase =			model(snake_case__					)
            self.parent.assertEqual(result.start_logits.shape,(self.batch_size, self.seq_length)					)
            self.parent.assertEqual(result.end_logits.shape,(self.batch_size, self.seq_length)					)







       def 		snake_case_	(			self: Tuple					):






            '''simple docstring'''




            __UpperCamelCase =			self.prepare_config_and_inputs()
            (
                (
                __UpperCamelCase       
            ),    (
                __UpperCamelCase       
            ),    (
                __UpperCamelCase       
            ),    (
                __UpperCamelCase       
            ),    (
                __UpperCamelCase       
            ),    (
                __UpperCamelCase       
            ),    (
                __UpperCamelCase       
            ),           
            ) =			config_and_inputs
            __UpperCamelCase =			{'input_ids': input_ids, 'token_type_ids': token_type_ids, 'attention_mask': input_mask}
            return config, inputs_dict



@require_tf
class 	__lowerCamelCase			(__UpperCamelCase				,      __UpperCamelCase				,      unittest.TestCase						):
       _lowercase											=     (
           (
               TFRoFormerModel,
               TFRoFormerForCausalLM,
               TFRoFormerForMaskedLM,
               TFRoFormerForQuestionAnswering,
               TFRoFormerForSequenceClassification,
               TFRoFormerForTokenClassification,
               TFRoFormerForMultipleChoice,
           )
           if is_tf_available()
           else ()
       )
       _lowercase											=     (
           {
               "feature-extraction": TFRoFormerModel,
               "fill-mask": TFRoFormerForMaskedLM,
               "question-answering": TFRoFormerForQuestionAnswering,
               "text-classification": TFRoFormerForSequenceClassification,
               "text-generation": TFRoFormerForCausalLM,
               "token-classification": TFRoFormerForTokenClassification,
               "zero-shot": TFRoFormerForSequenceClassification,
           }
           if is_tf_available()
           else {}
       )

       _lowercase											=     False
       _lowercase											=     False







       def 		snake_case_	(			self: Tuple,A_: Tuple,A_: Dict,A_: int,A_: Optional[int],A_: Optional[Any]					):






            '''simple docstring'''




            if pipeline_test_casse_name == "TextGenerationPipelineTests":
                 return True

            return False







       def 		snake_case_	(			self: Union[str, Any]					):






            '''simple docstring'''




            __UpperCamelCase =			TFRoFormerModelTester(self					)
            __UpperCamelCase =			ConfigTester(self,config_class=snake_case__,hidden_size=37					)







       def 		snake_case_	(			self: Optional[int]					):






            '''simple docstring'''




            self.config_tester.run_common_tests()







       def 		snake_case_	(			self: Optional[int]					):






            '''simple docstring'''




            __UpperCamelCase =			self.model_tester.prepare_config_and_inputs()
            self.model_tester.create_and_check_model(*snake_case__					)







       def 		snake_case_	(			self: List[str]					):






            '''simple docstring'''




            __UpperCamelCase =			self.model_tester.prepare_config_and_inputs()
            self.model_tester.create_and_check_for_masked_lm(*snake_case__					)







       def 		snake_case_	(			self: Union[str, Any]					):






            '''simple docstring'''




            __UpperCamelCase =			self.model_tester.prepare_config_and_inputs()
            self.model_tester.create_and_check_lm_head(*snake_case__					)







       def 		snake_case_	(			self: int					):






            '''simple docstring'''




            __UpperCamelCase =			self.model_tester.prepare_config_and_inputs()
            self.model_tester.create_and_check_for_multiple_choice(*snake_case__					)







       def 		snake_case_	(			self: List[Any]					):






            '''simple docstring'''




            __UpperCamelCase =			self.model_tester.prepare_config_and_inputs()
            self.model_tester.create_and_check_for_question_answering(*snake_case__					)







       def 		snake_case_	(			self: Optional[int]					):






            '''simple docstring'''




            __UpperCamelCase =			self.model_tester.prepare_config_and_inputs()
            self.model_tester.create_and_check_for_sequence_classification(*snake_case__					)







       def 		snake_case_	(			self: Optional[Any]					):






            '''simple docstring'''




            __UpperCamelCase =			self.model_tester.prepare_config_and_inputs()
            self.model_tester.create_and_check_for_token_classification(*snake_case__					)







       @slow
       def 		snake_case_	(			self: List[Any]					):






            '''simple docstring'''




            __UpperCamelCase =			TFRoFormerModel.from_pretrained('junnyu/roformer_chinese_base'					)
            self.assertIsNotNone(snake_case__					)



@require_tf
class 	__lowerCamelCase			(unittest.TestCase						):







       @slow
       def 		snake_case_	(			self: Dict					):






            '''simple docstring'''




            __UpperCamelCase =			TFRoFormerForMaskedLM.from_pretrained('junnyu/roformer_chinese_base'					)
            __UpperCamelCase =			tf.constant([[0, 1, 2, 3, 4, 5]]					)
            __UpperCamelCase =			model(snake_case__					)[0]

            # TODO Replace vocab size
            __UpperCamelCase =			5_0000

            __UpperCamelCase =			[1, 6, vocab_size]
            self.assertEqual(output.shape,snake_case__					)

            print(output[:, :3, :3]					)

            # TODO Replace values below with what was printed above.
            __UpperCamelCase =			tf.constant(
                [
                    [
                        [-0.1_2_0_5_3_3_4_1, -1.0_2_6_4_9_0_1, 0.2_9_2_2_1_9_4_6],
                        [-1.5_1_3_3_7_8_3, 0.1_9_7_4_3_3, 0.1_5_1_9_0_6_0_7],
                        [-5.0_1_3_5_4_0_3, -3.9_0_0_2_5_6, -0.8_4_0_3_8_7_6_4],
                    ]
                ]					)
            tf.debugging.assert_near(output[:, :3, :3],snake_case__,atol=1E-4					)



@require_tf
class 	__lowerCamelCase			(unittest.TestCase						):
       _lowercase											=     1e-4







       def 		snake_case_	(			self: Any					):






            '''simple docstring'''




            __UpperCamelCase =			tf.constant([[4, 10]]					)
            __UpperCamelCase =			TFRoFormerSinusoidalPositionalEmbedding(num_positions=6,embedding_dim=6					)

            __UpperCamelCase =			emba(input_ids.shape					)
            __UpperCamelCase =			tf.constant(
                [[0.0_0_0_0, 0.0_0_0_0, 0.0_0_0_0, 1.0_0_0_0, 1.0_0_0_0, 1.0_0_0_0], [0.8_4_1_5, 0.0_4_6_4, 0.0_0_2_2, 0.5_4_0_3, 0.9_9_8_9, 1.0_0_0_0]]					)

            tf.debugging.assert_near(snake_case__,snake_case__,atol=self.tolerance					)







       def 		snake_case_	(			self: List[Any]					):






            '''simple docstring'''




            __UpperCamelCase =			tf.constant(
                [
                    [0.0_0_0_0, 0.0_0_0_0, 0.0_0_0_0, 0.0_0_0_0, 0.0_0_0_0],
                    [0.8_4_1_5, 0.8_2_1_9, 0.8_0_2_0, 0.7_8_1_9, 0.7_6_1_7],
                    [0.9_0_9_3, 0.9_3_6_4, 0.9_5_8_1, 0.9_7_4_9, 0.9_8_7_0],
                ]					)
            __UpperCamelCase =			TFRoFormerSinusoidalPositionalEmbedding(num_positions=512,embedding_dim=512					)
            emba([2, 16, 512]					)
            __UpperCamelCase =			emba.weight[:3, :5]

            tf.debugging.assert_near(snake_case__,snake_case__,atol=self.tolerance					)



@require_tf
class 	__lowerCamelCase			(unittest.TestCase						):
       _lowercase											=     1e-4







       def 		snake_case_	(			self: Union[str, Any]					):






            '''simple docstring'''




            __UpperCamelCase =			tf.reshape(tf.range(2 * 12 * 16 * 64,dtype=tf.floataa					),shape=(2, 12, 16, 64)					) / 100

            __UpperCamelCase =			-tf.reshape(tf.range(2 * 12 * 16 * 64,dtype=tf.floataa					),shape=(2, 12, 16, 64)					) / 100

            __UpperCamelCase =			TFRoFormerSinusoidalPositionalEmbedding(num_positions=32,embedding_dim=64					)
            __UpperCamelCase =			embed_positions([2, 16, 768]					)[None, None, :, :]

            __UpperCamelCase,    __UpperCamelCase =			TFRoFormerSelfAttention.apply_rotary_position_embeddings(
                snake_case__,snake_case__,snake_case__					)

            __UpperCamelCase =			tf.constant(
                [
                    [0.0_0_0_0, 0.0_1_0_0, 0.0_2_0_0, 0.0_3_0_0, 0.0_4_0_0, 0.0_5_0_0, 0.0_6_0_0, 0.0_7_0_0],
                    [-0.2_0_1_2, 0.8_8_9_7, 0.0_2_6_3, 0.9_4_0_1, 0.2_0_7_4, 0.9_4_6_3, 0.3_4_8_1, 0.9_3_4_3],
                    [-1.7_0_5_7, 0.6_2_7_1, -1.2_1_4_5, 1.3_8_9_7, -0.6_3_0_3, 1.7_6_4_7, -0.1_1_7_3, 1.8_9_8_5],
                    [-2.1_7_3_1, -1.6_3_9_7, -2.7_3_5_8, 0.2_8_5_4, -2.1_8_4_0, 1.7_1_8_3, -1.3_0_1_8, 2.4_8_7_1],
                    [0.2_7_1_7, -3.6_1_7_3, -2.9_2_0_6, -2.1_9_8_8, -3.6_6_3_8, 0.3_8_5_8, -2.9_1_5_5, 2.2_9_8_0],
                    [3.9_8_5_9, -2.1_5_8_0, -0.7_9_8_4, -4.4_9_0_4, -4.1_1_8_1, -2.0_2_5_2, -4.4_7_8_2, 1.1_2_5_3],
                ]					)
            __UpperCamelCase =			tf.constant(
                [
                    [0.0_0_0_0, -0.0_1_0_0, -0.0_2_0_0, -0.0_3_0_0, -0.0_4_0_0, -0.0_5_0_0, -0.0_6_0_0, -0.0_7_0_0],
                    [0.2_0_1_2, -0.8_8_9_7, -0.0_2_6_3, -0.9_4_0_1, -0.2_0_7_4, -0.9_4_6_3, -0.3_4_8_1, -0.9_3_4_3],
                    [1.7_0_5_7, -0.6_2_7_1, 1.2_1_4_5, -1.3_8_9_7, 0.6_3_0_3, -1.7_6_4_7, 0.1_1_7_3, -1.8_9_8_5],
                    [2.1_7_3_1, 1.6_3_9_7, 2.7_3_5_8, -0.2_8_5_4, 2.1_8_4_0, -1.7_1_8_3, 1.3_0_1_8, -2.4_8_7_1],
                    [-0.2_7_1_7, 3.6_1_7_3, 2.9_2_0_6, 2.1_9_8_8, 3.6_6_3_8, -0.3_8_5_8, 2.9_1_5_5, -2.2_9_8_0],
                    [-3.9_8_5_9, 2.1_5_8_0, 0.7_9_8_4, 4.4_9_0_4, 4.1_1_8_1, 2.0_2_5_2, 4.4_7_8_2, -1.1_2_5_3],
                ]					)

            tf.debugging.assert_near(query_layer[0, 0, :6, :8],snake_case__,atol=self.tolerance					)
            tf.debugging.assert_near(key_layer[0, 0, :6, :8],snake_case__,atol=self.tolerance					)



"""simple docstring"""




from typing import Optional, Tuple

import jax
import jax.numpy as jnp
from flax import linen as nn
from flax.core.frozen_dict import FrozenDict
from transformers import CLIPConfig, FlaxPreTrainedModel
from transformers.models.clip.modeling_flax_clip import FlaxCLIPVisionModule







def 				_UpperCAmelCase		(							lowerCamelCase__      ,	lowerCamelCase__      ,	lowerCamelCase__=1e-12  ):





		"""simple docstring"""




		lowerCAmelCase__   = jnp.divide(emb_a.T      ,	jnp.clip(jnp.linalg.norm(lowerCamelCase__      ,	axis=1  )      ,	a_min=lowerCamelCase__  )  ).T
		lowerCAmelCase__   = jnp.divide(emb_a.T      ,	jnp.clip(jnp.linalg.norm(lowerCamelCase__      ,	axis=1  )      ,	a_min=lowerCamelCase__  )  ).T
		return jnp.matmul(lowerCamelCase__      ,	norm_emb_a.T  )

class    a_   (  nn.Module      ):
					UpperCamelCase_			:						CLIPConfig
					UpperCamelCase_			:						jnp.dtype      =     jnp.floataa




					def     _SCREAMING_SNAKE_CASE    (						self    :  Tuple  ):
							lowerCAmelCase__   = FlaxCLIPVisionModule(self.config.vision_config  )
							lowerCAmelCase__   = nn.Dense(self.config.projection_dim	,    use_bias=snake_case__	,    dtype=self.dtype  )

							lowerCAmelCase__   = self.param("""concept_embeds"""	,    jax.nn.initializers.ones	,    (17, self.config.projection_dim)  )
							lowerCAmelCase__   = self.param(
							    """special_care_embeds"""	,    jax.nn.initializers.ones	,    (3, self.config.projection_dim)  )

							lowerCAmelCase__   = self.param("""concept_embeds_weights"""	,    jax.nn.initializers.ones	,    (17,)  )
							lowerCAmelCase__   = self.param("""special_care_embeds_weights"""	,    jax.nn.initializers.ones	,    (3,)  )




					def __call__(						self    :  Optional[int]	,    snake_case__    :  int  ):
							lowerCAmelCase__   = self.vision_model(snake_case__  )[1]
							lowerCAmelCase__   = self.visual_projection(snake_case__  )

							lowerCAmelCase__   = jax_cosine_distance(snake_case__	,    self.special_care_embeds  )
							lowerCAmelCase__   = jax_cosine_distance(snake_case__	,    self.concept_embeds  )

							# increase this value to create a stronger `nfsw` filter
							# at the cost of increasing the possibility of filtering benign image inputs
							lowerCAmelCase__   = 0.0

							lowerCAmelCase__   = special_cos_dist - self.special_care_embeds_weights[None, :] + adjustment
							lowerCAmelCase__   = jnp.round(snake_case__	,    3  )
							lowerCAmelCase__   = jnp.any(special_scores > 0	,    axis=1	,    keepdims=snake_case__  )
							# Use a lower threshold if an image has any special care concept
							lowerCAmelCase__   = is_special_care * 0.01

							lowerCAmelCase__   = cos_dist - self.concept_embeds_weights[None, :] + special_adjustment
							lowerCAmelCase__   = jnp.round(snake_case__	,    3  )
							lowerCAmelCase__   = jnp.any(concept_scores > 0	,    axis=1  )

							return has_nsfw_concepts

class    a_   (  __UpperCamelCase      ):
					UpperCamelCase_			:						Any      =     CLIPConfig
					UpperCamelCase_			:						str      =     "clip_input"
					UpperCamelCase_			:						str      =     FlaxStableDiffusionSafetyCheckerModule




					def __init__(						self    :  Optional[int]	,    snake_case__    :  CLIPConfig	,    snake_case__    :  Optional[Tuple] = None	,    snake_case__    :  int = 0	,    snake_case__    :  jnp.dtype = jnp.floataa	,    snake_case__    :  bool = True	,    **snake_case__    :  str	,    ):
							if input_shape is None:
									lowerCAmelCase__   = (1, 224, 224, 3)
							lowerCAmelCase__   = self.module_class(config=snake_case__	,    dtype=snake_case__	,    **snake_case__  )
							super().__init__(snake_case__	,    snake_case__	,    input_shape=snake_case__	,    seed=snake_case__	,    dtype=snake_case__	,    _do_init=_do_init  )




					def     _SCREAMING_SNAKE_CASE    (						self    :  Tuple	,    snake_case__    :  jax.random.KeyArray	,    snake_case__    :  Tuple	,    snake_case__    :  FrozenDict = None  ):
							# init input tensor
							lowerCAmelCase__   = jax.random.normal(snake_case__	,    snake_case__  )

							lowerCAmelCase__ ,       lowerCAmelCase__   = jax.random.split(snake_case__  )
							lowerCAmelCase__   = {"""params""": params_rng, """dropout""": dropout_rng}

							lowerCAmelCase__   = self.module.init(snake_case__	,    snake_case__  )["""params"""]

							return random_params




					def __call__(						self    :  Union[str, Any]	,    snake_case__    :  Union[str, Any]	,    snake_case__    :  dict = None	,    ):
							lowerCAmelCase__   = jnp.transpose(snake_case__	,    (0, 2, 3, 1)  )

							return self.module.apply(
							    {"""params""": params or self.params}	,    jnp.array(snake_case__	,    dtype=jnp.floataa  )	,    rngs={}	,    )




