
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     __lowerCAmelCase			(			a__						,    a__						,    a__=1e-12  )       ->  Optional[int]:
				__a										=    jnp.divide(emb_a.T						,    jnp.clip(jnp.linalg.norm(a__						,    axis=1  )						,    a_min=a__  )  ).T
				__a										=    jnp.divide(emb_a.T						,    jnp.clip(jnp.linalg.norm(a__						,    axis=1  )						,    a_min=a__  )  ).T
				return jnp.matmul(a__						,    norm_emb_a.T  )







class 			__A( nn.Module			):
				snake_case_						   =    42
				snake_case_						   =    jnp.floataa




				def 				SCREAMING_SNAKE_CASE_		(     self				)    ->      List[Any]:


								'''simple docstring'''




								__a										=    FlaxCLIPVisionModule(self.config.vision_config				)
								__a										=    nn.Dense(self.config.projection_dim		,     use_bias=_snake_case		,     dtype=self.dtype				)

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

								__a										=    self.param('''concept_embeds_weights'''		,     jax.nn.initializers.ones		,     (17,)				)
								__a										=    self.param('''special_care_embeds_weights'''		,     jax.nn.initializers.ones		,     (3,)				)




				def __call__(     self		,     _snake_case				)    ->      List[str]:


								'''simple docstring'''




								__a										=    self.vision_model(_snake_case				)[1]
								__a										=    self.visual_projection(_snake_case				)

								__a										=    jax_cosine_distance(_snake_case		,     self.special_care_embeds				)
								__a										=    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
								__a										=    0.0

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

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

								return has_nsfw_concepts







class 			__A( a			):
				snake_case_						   =    CLIPConfig
				snake_case_						   =    '''clip_input'''
				snake_case_						   =    FlaxStableDiffusionSafetyCheckerModule




				def __init__(     self		,     _snake_case		,     _snake_case = None		,     _snake_case = 0		,     _snake_case = jnp.floataa		,     _snake_case = True		,     **_snake_case		,     )    ->      Union[str, Any]:


								'''simple docstring'''




								if input_shape is None:
												__a										=    (1, 224, 224, 3)
								__a										=    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		,     _snake_case		,     _snake_case		,     _snake_case = None				)    ->      FrozenDict:


								'''simple docstring'''




								__a										=    jax.random.normal(_snake_case		,     _snake_case				)

								__a							,     __a										=    jax.random.split(_snake_case				)
								__a										=    {'''params''': params_rng, '''dropout''': dropout_rng}

								__a										=    self.module.init(_snake_case		,     _snake_case				)['''params''']

								return random_params




				def __call__(     self		,     _snake_case		,     _snake_case = None		,     )    ->      List[Any]:


								'''simple docstring'''




								__a										=    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={}		,     )

from math import ceil


def     __lowerCAmelCase			(			a__ = 1001  )       ->  int:
				__a										=    1

				for i in range(1						,    int(ceil(n / 2.0  )  )  ):
								__a										=    2 * i + 1
								__a										=    2 * i
								__a										=    total + 4 * odd**2 - 6 * even

				return total


if __name__ == "__main__":
					import sys

					if len(sys.argv) == 1:
										print(solution())
					else:
										try:
															A     :	List[Any]    = int(sys.argv[1])
															print(solution(n))
										except ValueError:
															print('Invalid entry - please enter a number')