


'''simple docstring'''





from typing import Optional, Tuple

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

from transformers import FLAX_MODEL_MAPPING, FlaxCLIPVisionModel
from transformers.modeling_flax_utils import FlaxPreTrainedModel
from transformers.models.clip.modeling_flax_clip import FlaxCLIPOutput
from transformers.utils import logging


__lowerCamelCase       				=	logging.get_logger(__name__)




class 							UpperCAmelCase ( nn.Module	):
 UpperCAmelCase				=				42
 UpperCAmelCase				=				jnp.floataa


 def 					__SCREAMING_SNAKE_CASE				(			self       :  Any   ):
    UpperCAmelCase__  :str            =			self.config.text_config
    UpperCAmelCase__  :Union[str, Any]            =			self.config.vision_config

    UpperCAmelCase__  :int            =			self.config.projection_dim
    UpperCAmelCase__  :int            =			text_config.hidden_size
    UpperCAmelCase__  :Tuple            =			vision_config.hidden_size

    UpperCAmelCase__  :Tuple            =			FLAX_MODEL_MAPPING[self.config.text_config.__class__].module_class
    UpperCAmelCase__  :Dict            =			FLAX_MODEL_MAPPING.get(self.config.vision_config.__class__ ,					__lowerCamelCase   ).module_class

    UpperCAmelCase__  :Any            =			text_module(__lowerCamelCase ,					dtype=self.dtype   )
    UpperCAmelCase__  :Tuple            =			vision_module(__lowerCamelCase ,					dtype=self.dtype   )

    UpperCAmelCase__  :List[str]            =			nn.Dense(
        self.projection_dim ,					dtype=self.dtype ,					kernel_init=jax.nn.initializers.normal(0.02   ) ,					use_bias=__lowerCamelCase ,					)
    UpperCAmelCase__  :List[Any]            =			nn.Dense(
        self.projection_dim ,					dtype=self.dtype ,					kernel_init=jax.nn.initializers.normal(0.02   ) ,					use_bias=__lowerCamelCase ,					)
    UpperCAmelCase__  :str            =			self.param('''logit_scale''' ,					jax.nn.initializers.ones ,					[]   )





 def __call__(			self       :  Optional[Any] ,					__lowerCamelCase       :  Dict=None ,					__lowerCamelCase       :  List[str]=None ,					__lowerCamelCase       :  Tuple=None ,					__lowerCamelCase       :  Optional[Any]=None ,					__lowerCamelCase       :  str=None ,					__lowerCamelCase       :  bool = True ,					__lowerCamelCase       :  Dict=None ,					__lowerCamelCase       :  Union[str, Any]=None ,					__lowerCamelCase       :  Optional[Any]=None ,					):
    UpperCAmelCase__  :Optional[Any]            =			return_dict if return_dict is not None else self.config.return_dict

    UpperCAmelCase__  :str            =			self.vision_model(
        pixel_values=__lowerCamelCase ,					deterministic=__lowerCamelCase ,					output_attentions=__lowerCamelCase ,					output_hidden_states=__lowerCamelCase ,					return_dict=__lowerCamelCase ,					)

    UpperCAmelCase__  :List[str]            =			self.text_model(
        input_ids=__lowerCamelCase ,					attention_mask=__lowerCamelCase ,					token_type_ids=__lowerCamelCase ,					position_ids=__lowerCamelCase ,					deterministic=__lowerCamelCase ,					output_attentions=__lowerCamelCase ,					output_hidden_states=__lowerCamelCase ,					return_dict=__lowerCamelCase ,					)

    UpperCAmelCase__  :int            =			vision_outputs[1]
    UpperCAmelCase__  :Tuple            =			self.visual_projection(__lowerCamelCase   )

    UpperCAmelCase__  :Dict            =			text_outputs[1]
    UpperCAmelCase__  :int            =			self.text_projection(__lowerCamelCase   )

    # normalized features
    UpperCAmelCase__  :Optional[int]            =			image_embeds / jnp.linalg.norm(__lowerCamelCase ,					axis=-1 ,					keepdims=__lowerCamelCase   )
    UpperCAmelCase__  :Tuple            =			text_embeds / jnp.linalg.norm(__lowerCamelCase ,					axis=-1 ,					keepdims=__lowerCamelCase   )

    # cosine similarity as logits
    UpperCAmelCase__  :List[str]            =			jnp.exp(self.logit_scale   )
    UpperCAmelCase__  :Union[str, Any]            =			jnp.matmul(__lowerCamelCase ,					image_embeds.T   ) * logit_scale
    UpperCAmelCase__  :Dict            =			logits_per_text.T

    if not return_dict:
       return (logits_per_image, logits_per_text, text_embeds, image_embeds, text_outputs, vision_outputs)

    return FlaxCLIPOutput(
        logits_per_image=__lowerCamelCase ,					logits_per_text=__lowerCamelCase ,					text_embeds=__lowerCamelCase ,					image_embeds=__lowerCamelCase ,					text_model_output=__lowerCamelCase ,					vision_model_output=__lowerCamelCase ,					)




class 							UpperCAmelCase ( _snake_case	):
 UpperCAmelCase				=				HybridCLIPConfig
 UpperCAmelCase				=				FlaxHybridCLIPModule


 def __init__(			self       :  int ,					__lowerCamelCase       :  HybridCLIPConfig ,					__lowerCamelCase       :  Optional[Tuple] = None ,					__lowerCamelCase       :  int = 0 ,					__lowerCamelCase       :  jnp.dtype = jnp.floataa ,					**__lowerCamelCase       :  Any ,					):
    if input_shape is None:
       UpperCAmelCase__  :str            =			((1, 1), (1, config.vision_config.image_size, config.vision_config.image_size, 3))

    UpperCAmelCase__  :Union[str, Any]            =			self.module_class(config=__lowerCamelCase ,					dtype=__lowerCamelCase ,					**__lowerCamelCase   )
    super().__init__(__lowerCamelCase ,					__lowerCamelCase ,					input_shape=__lowerCamelCase ,					seed=__lowerCamelCase ,					dtype=__lowerCamelCase   )


 def 					__SCREAMING_SNAKE_CASE				(			self       :  Optional[int] ,					__lowerCamelCase       :  jax.random.PRNGKey ,					__lowerCamelCase       :  Tuple ,					__lowerCamelCase       :  FrozenDict = None   ):
    # init input tensor
    UpperCAmelCase__  :Optional[Any]            =			jnp.zeros(input_shape[0] ,					dtype='''i4'''   )
    UpperCAmelCase__  :int            =			jnp.broadcast_to(jnp.arange(jnp.atleast_ad(__lowerCamelCase   ).shape[-1]   ) ,					input_shape[0]   )
    UpperCAmelCase__  :List[str]            =			jnp.ones_like(__lowerCamelCase   )
    UpperCAmelCase__  :Any            =			jnp.ones_like(__lowerCamelCase   )

    UpperCAmelCase__  :Tuple            =			jax.random.normal(__lowerCamelCase ,					input_shape[1]   )

    UpperCAmelCase__      ,	UpperCAmelCase__  :Any            =			jax.random.split(__lowerCamelCase   )
    UpperCAmelCase__  :List[Any]            =			{'''params''': params_rng, '''dropout''': dropout_rng}

    return self.module.init(__lowerCamelCase ,					__lowerCamelCase ,					__lowerCamelCase ,					__lowerCamelCase ,					__lowerCamelCase ,					__lowerCamelCase   )["params"]


 def __call__(			self       :  Union[str, Any] ,					__lowerCamelCase       :  List[Any] ,					__lowerCamelCase       :  Optional[int] ,					__lowerCamelCase       :  Union[str, Any]=None ,					__lowerCamelCase       :  Tuple=None ,					__lowerCamelCase       :  Optional[int]=None ,					__lowerCamelCase       :  dict = None ,					__lowerCamelCase       :  jax.random.PRNGKey = None ,					__lowerCamelCase       :  bool = False ,					__lowerCamelCase       :  Optional[bool] = None ,					__lowerCamelCase       :  Optional[bool] = None ,					__lowerCamelCase       :  Optional[bool] = None ,					):
    UpperCAmelCase__  :int            =			output_attentions if output_attentions is not None else self.config.output_attentions
    UpperCAmelCase__  :Optional[Any]            =			(
        output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
    )
    UpperCAmelCase__  :List[str]            =			return_dict if return_dict is not None else self.config.return_dict

    if position_ids is None:
       UpperCAmelCase__  :List[str]            =			jnp.broadcast_to(jnp.arange(jnp.atleast_ad(__lowerCamelCase   ).shape[-1]   ) ,					input_ids.shape   )

    if token_type_ids is None:
       UpperCAmelCase__  :str            =			jnp.zeros_like(__lowerCamelCase   )

    if attention_mask is None:
       UpperCAmelCase__  :Optional[Any]            =			jnp.ones_like(__lowerCamelCase   )

    # Handle any PRNG if needed
    UpperCAmelCase__  :Optional[int]            =			{}
    if dropout_rng is not None:
       UpperCAmelCase__  :List[Any]            =			dropout_rng

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


 def 					__SCREAMING_SNAKE_CASE				(			self       :  Optional[Any] ,					__lowerCamelCase       :  Dict ,					__lowerCamelCase       :  Any=None ,					__lowerCamelCase       :  List[Any]=None ,					__lowerCamelCase       :  int=None ,					__lowerCamelCase       :  dict = None ,					__lowerCamelCase       :  jax.random.PRNGKey = None ,					__lowerCamelCase       :  Tuple=False ,					):
    if position_ids is None:
       UpperCAmelCase__  :Union[str, Any]            =			jnp.broadcast_to(jnp.arange(jnp.atleast_ad(__lowerCamelCase   ).shape[-1]   ) ,					input_ids.shape   )

    if token_type_ids is None:
       UpperCAmelCase__  :Optional[Any]            =			jnp.zeros_like(__lowerCamelCase   )

    if attention_mask is None:
       UpperCAmelCase__  :Tuple            =			jnp.ones_like(__lowerCamelCase   )

    # Handle any PRNG if needed
    UpperCAmelCase__  :List[str]            =			{}
    if dropout_rng is not None:
       UpperCAmelCase__  :int            =			dropout_rng

    def _get_features(__lowerCamelCase       :  List[str] ,					__lowerCamelCase       :  Union[str, Any] ,					__lowerCamelCase       :  List[str] ,					__lowerCamelCase       :  int ,					__lowerCamelCase       :  Union[str, Any] ,					__lowerCamelCase       :  Tuple   ):
       UpperCAmelCase__  :Tuple            =			module.text_model(
           input_ids=__lowerCamelCase ,					attention_mask=__lowerCamelCase ,					position_ids=__lowerCamelCase ,					token_type_ids=__lowerCamelCase ,					deterministic=__lowerCamelCase ,					)
       UpperCAmelCase__  :Any            =			text_outputs[1]
       UpperCAmelCase__  :Dict            =			module.text_projection(__lowerCamelCase   )
       return text_features

    return self.module.apply(
        {'''params''': params or self.params} ,					jnp.array(__lowerCamelCase ,					dtype='''i4'''   ) ,					jnp.array(__lowerCamelCase ,					dtype='''i4'''   ) ,					jnp.array(__lowerCamelCase ,					dtype='''i4'''   ) ,					jnp.array(__lowerCamelCase ,					dtype='''i4'''   ) ,					not train ,					method=_get_features ,					rngs=__lowerCamelCase ,					)


 def 					__SCREAMING_SNAKE_CASE				(			self       :  str ,					__lowerCamelCase       :  List[str] ,					__lowerCamelCase       :  dict = None ,					__lowerCamelCase       :  jax.random.PRNGKey = None ,					__lowerCamelCase       :  Optional[Any]=False   ):
    UpperCAmelCase__  :List[Any]            =			{}
    if dropout_rng is not None:
       UpperCAmelCase__  :Optional[int]            =			dropout_rng

    def _get_features(__lowerCamelCase       :  Tuple ,					__lowerCamelCase       :  Dict ,					__lowerCamelCase       :  str   ):
       UpperCAmelCase__  :Any            =			module.vision_model(pixel_values=__lowerCamelCase ,					deterministic=__lowerCamelCase   )
       UpperCAmelCase__  :Any            =			vision_outputs[1]  # pooled_output
       UpperCAmelCase__  :List[str]            =			module.visual_projection(__lowerCamelCase   )
       return image_features

    return self.module.apply(
        {'''params''': params or self.params} ,					jnp.array(__lowerCamelCase ,					dtype=jnp.floataa   ) ,					not train ,					method=_get_features ,					rngs=__lowerCamelCase ,					)





 @classmethod
 def 					__SCREAMING_SNAKE_CASE				(			cls       :  Optional[Any] ,					__lowerCamelCase       :  str = None ,					__lowerCamelCase       :  str = None ,					*__lowerCamelCase       :  int ,					**__lowerCamelCase       :  Any ,					):
    UpperCAmelCase__  :int            =			{
        argument[len('''text_'''   ) :]: value for argument, value in kwargs.items() if argument.startswith('''text_'''   )
    }

    UpperCAmelCase__  :Optional[int]            =			{
        argument[len('''vision_'''   ) :]: value for argument, value in kwargs.items() if argument.startswith('''vision_'''   )
    }

    # remove text, vision kwargs from kwargs
    for key in kwargs_text.keys():
       del kwargs["text_" + key]
    for key in kwargs_vision.keys():
       del kwargs["vision_" + key]

    # Load and initialize the text and vision model
    UpperCAmelCase__  :List[str]            =			kwargs_text.pop('''model''' ,					__lowerCamelCase   )
    if text_model is None:
       assert (
           text_model_name_or_path is not None
       ), "If `model` is not defined as an argument, a `text_model_name_or_path` has to be defined"
       from transformers import FlaxAutoModel

       if "config" not in kwargs_text:
          from transformers import AutoConfig

          UpperCAmelCase__  :str            =			AutoConfig.from_pretrained(__lowerCamelCase   )
          UpperCAmelCase__  :Any            =			text_config

       UpperCAmelCase__  :Dict            =			FlaxAutoModel.from_pretrained(__lowerCamelCase ,					*__lowerCamelCase ,					**__lowerCamelCase   )

    UpperCAmelCase__  :Optional[Any]            =			kwargs_vision.pop('''model''' ,					__lowerCamelCase   )
    if vision_model is None:
       assert (
           vision_model_name_or_path is not None
       ), "If `model` is not defined as an argument, a `vision_model_name_or_path` has to be defined"
       from transformers import FlaxAutoModel

       if "config" not in kwargs_vision:
          from transformers import AutoConfig

          UpperCAmelCase__  :int            =			AutoConfig.from_pretrained(__lowerCamelCase   )
          UpperCAmelCase__  :Any            =			vision_config

       UpperCAmelCase__  :Dict            =			FlaxAutoModel.from_pretrained(__lowerCamelCase ,					*__lowerCamelCase ,					**__lowerCamelCase   )

    # instantiate config with corresponding kwargs
    UpperCAmelCase__  :Optional[Any]            =			kwargs.pop('''dtype''' ,					jnp.floataa   )
    UpperCAmelCase__  :List[str]            =			HybridCLIPConfig.from_text_vision_configs(text_model.config ,					vision_model.config ,					**__lowerCamelCase   )

    # init model
    UpperCAmelCase__  :Optional[Any]            =			cls(__lowerCamelCase ,					*__lowerCamelCase ,					dtype=__lowerCamelCase ,					**__lowerCamelCase   )

    if vision_config.model_type == "clip":
       UpperCAmelCase__  :Union[str, Any]            =			vision_model.params['''vision_model''']
       UpperCAmelCase__  :Union[str, Any]            =			vision_model.params['''visual_projection''']['''kernel''']
    else:
       UpperCAmelCase__  :Tuple            =			vision_model.params

    UpperCAmelCase__  :Optional[Any]            =			text_model.params

    return model







'''simple docstring'''





def 					a__    (				UpperCamelCase_	:			int = 100	):
   UpperCAmelCase__  :List[str]            =			1
   UpperCAmelCase__  :Dict            =			0
   for i in range(1,      num + 1	):
      fact *= i

   for j in str(UpperCamelCase_	):
      result += int(UpperCamelCase_	)

   return result


if __name__ == "__main__":
    print(solution(int(input('''Enter the Number: ''').strip())))



