




'''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	(			a		,						a		,						a=1e-12			)				->     List[str]:






     '''simple docstring'''
     __magic_name__						       =    jnp.divide(emb_a.T		,						jnp.clip(jnp.linalg.norm(a		,						axis=1			)		,						a_min=a			)			).T
     __magic_name__						       =    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   _SCREAMING_SNAKE_CASE   (   nn.Module     ):
 __SCREAMING_SNAKE_CASE					:CLIPConfig
 __SCREAMING_SNAKE_CASE					:jnp.dtype      	=					jnp.floataa



 def 			snake_case__  (   self		:   Any      ):
      __magic_name__						       =    FlaxCLIPVisionModule(self.config.vision_config      )
      __magic_name__						       =    nn.Dense(self.config.projection_dim			,				use_bias=a__			,				dtype=self.dtype      )

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

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



 def __call__(   self		:   Any			,				a__		:   List[str]      ):
      __magic_name__						       =    self.vision_model(a__      )[1]
      __magic_name__						       =    self.visual_projection(a__      )

      __magic_name__						       =    jax_cosine_distance(a__			,				self.special_care_embeds      )
      __magic_name__						       =    jax_cosine_distance(a__			,				self.concept_embeds      )

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

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

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

      return has_nsfw_concepts






class   _SCREAMING_SNAKE_CASE   (   __a     ):
 __SCREAMING_SNAKE_CASE					:Optional[Any]      	=					CLIPConfig
 __SCREAMING_SNAKE_CASE					:int      	=					"""clip_input"""
 __SCREAMING_SNAKE_CASE					:Tuple      	=					FlaxStableDiffusionSafetyCheckerModule



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



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

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

      __magic_name__						       =    self.module.init(a__			,				a__      )['''params''']

      return random_params



 def __call__(   self		:   Optional[Any]			,				a__		:   Dict			,				a__		:   dict = None			,				):
      __magic_name__						       =    jnp.transpose(a__			,				(0, 2, 3, 1)      )

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









'''simple docstring'''




from __future__ import annotations

from fractions import Fraction




def 						UpperCamelCase	(			a		,						a			)				->     bool:






     '''simple docstring'''
     return (
         num != den and num % 10 == den // 10 and (num // 10) / (den % 10) == num / den
     )




def 						UpperCamelCase	(			a			)				->     list[str]:






     '''simple docstring'''
     __magic_name__						       =    []
     __magic_name__						       =    11
     __magic_name__						       =    int('''1''' + '''0''' * digit_len			)
     for num in range(a		,						a			):
          while den <= 99:
               if (num != den) and (num % 10 == den // 10) and (den % 10 != 0):
                    if is_digit_cancelling(a		,						a			):
                         solutions.append(F'''{num}/{den}'''			)
               den += 1
          num += 1
          __magic_name__						       =    10
     return solutions




def 						UpperCamelCase	(			a = 2			)				->     int:






     '''simple docstring'''
     __magic_name__						       =    1.0
     for fraction in fraction_list(a			):
          __magic_name__						       =    Fraction(a			)
          result *= frac.denominator / frac.numerator
     return int(a			)


if __name__ == "__main__":
      print(solution())






