




'''simple docstring'''



import torch
import torch.nn as nn
from transformers import CLIPConfig, CLIPVisionModel, PreTrainedModel

from ...utils import logging


lowerCamelCase_			=						logging.get_logger(__name__)
def 			SCREAMING_SNAKE_CASE_			(							__A    :			Dict	,					__A    :			Any  )			->			Dict:
   _SCREAMING_SNAKE_CASE	=				nn.functional.normalize(__A  )
   _SCREAMING_SNAKE_CASE	=				nn.functional.normalize(__A  )
   return torch.mm(__A	,					normalized_text_embeds.t()  )







class 		lowercase_   (			A       ):


   """simple docstring"""

   lowerCamelCase_      =						CLIPConfig

   lowerCamelCase_      =						['''CLIPEncoderLayer''']



   def __init__(   self :     int  ,				__lowerCamelCase :     CLIPConfig   ):

      """simple docstring"""
      super().__init__(__lowerCamelCase   )

      _SCREAMING_SNAKE_CASE	=				CLIPVisionModel(config.vision_config   )
      _SCREAMING_SNAKE_CASE	=				nn.Linear(config.vision_config.hidden_size  ,				config.projection_dim  ,				bias=__lowerCamelCase   )

      _SCREAMING_SNAKE_CASE	=				nn.Parameter(torch.ones(1_7  ,				config.projection_dim   )  ,				requires_grad=__lowerCamelCase   )
      _SCREAMING_SNAKE_CASE	=				nn.Parameter(torch.ones(3  ,				config.projection_dim   )  ,				requires_grad=__lowerCamelCase   )

      _SCREAMING_SNAKE_CASE	=				nn.Parameter(torch.ones(1_7   )  ,				requires_grad=__lowerCamelCase   )
      _SCREAMING_SNAKE_CASE	=				nn.Parameter(torch.ones(3   )  ,				requires_grad=__lowerCamelCase   )



   @torch.no_grad()
   def 							lowerCAmelCase_      (   self :     List[Any]  ,				__lowerCamelCase :     Optional[int]  ,				__lowerCamelCase :     Optional[int]   ):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE	=				self.vision_model(__lowerCamelCase   )[1]  # pooled_output
      _SCREAMING_SNAKE_CASE	=				self.visual_projection(__lowerCamelCase   )

      # we always cast to float32 as this does not cause significant overhead and is compatible with bfloat16
      _SCREAMING_SNAKE_CASE	=				cosine_distance(__lowerCamelCase  ,				self.special_care_embeds   ).cpu().float().numpy()
      _SCREAMING_SNAKE_CASE	=				cosine_distance(__lowerCamelCase  ,				self.concept_embeds   ).cpu().float().numpy()

      _SCREAMING_SNAKE_CASE	=				[]
      _SCREAMING_SNAKE_CASE	=				image_embeds.shape[0]
      for i in range(__lowerCamelCase   ):
         _SCREAMING_SNAKE_CASE	=				{"special_scores": {}, "special_care": [], "concept_scores": {}, "bad_concepts": []}

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

         for concept_idx in range(len(special_cos_dist[0]   )   ):
            _SCREAMING_SNAKE_CASE	=				special_cos_dist[i][concept_idx]
            _SCREAMING_SNAKE_CASE	=				self.special_care_embeds_weights[concept_idx].item()
            _SCREAMING_SNAKE_CASE	=				round(concept_cos - concept_threshold + adjustment  ,				3   )
            if result_img["special_scores"][concept_idx] > 0:
               result_img["special_care"].append({concept_idx, result_img["special_scores"][concept_idx]}   )
               _SCREAMING_SNAKE_CASE	=				0.0_1

         for concept_idx in range(len(cos_dist[0]   )   ):
            _SCREAMING_SNAKE_CASE	=				cos_dist[i][concept_idx]
            _SCREAMING_SNAKE_CASE	=				self.concept_embeds_weights[concept_idx].item()
            _SCREAMING_SNAKE_CASE	=				round(concept_cos - concept_threshold + adjustment  ,				3   )
            if result_img["concept_scores"][concept_idx] > 0:
               result_img["bad_concepts"].append(__lowerCamelCase   )

         result.append(__lowerCamelCase   )

      _SCREAMING_SNAKE_CASE	=				[len(res["bad_concepts"]   ) > 0 for res in result]

      return images, has_nsfw_concepts



   @torch.no_grad()
   def 							lowerCAmelCase_      (   self :     Optional[int]  ,				__lowerCamelCase :     torch.FloatTensor  ,				__lowerCamelCase :     torch.FloatTensor   ):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE	=				self.vision_model(__lowerCamelCase   )[1]  # pooled_output
      _SCREAMING_SNAKE_CASE	=				self.visual_projection(__lowerCamelCase   )

      _SCREAMING_SNAKE_CASE	=				cosine_distance(__lowerCamelCase  ,				self.special_care_embeds   )
      _SCREAMING_SNAKE_CASE	=				cosine_distance(__lowerCamelCase  ,				self.concept_embeds   )

      # increase this value to create a stronger `nsfw` filter
      # at the cost of increasing the possibility of filtering benign images
      _SCREAMING_SNAKE_CASE	=				0.0

      _SCREAMING_SNAKE_CASE	=				special_cos_dist - self.special_care_embeds_weights + adjustment
      # special_scores = special_scores.round(decimals=3)
      _SCREAMING_SNAKE_CASE	=				torch.any(special_scores > 0  ,				dim=1   )
      _SCREAMING_SNAKE_CASE	=				special_care * 0.0_1
      _SCREAMING_SNAKE_CASE	=				special_adjustment.unsqueeze(1   ).expand(-1  ,				cos_dist.shape[1]   )

      _SCREAMING_SNAKE_CASE	=				(cos_dist - self.concept_embeds_weights) + special_adjustment
      # concept_scores = concept_scores.round(decimals=3)
      _SCREAMING_SNAKE_CASE	=				torch.any(concept_scores > 0  ,				dim=1   )

      return images, has_nsfw_concepts







'''simple docstring'''



def 			SCREAMING_SNAKE_CASE_			(							__A    :			int  )			->			int:
   if n == 1 or not isinstance(__A	,					__A  ):
      return 0
   elif n == 2:
      return 1
   else:
      _SCREAMING_SNAKE_CASE	=				[0, 1]
      for i in range(2	,					n + 1  ):
         sequence.append(sequence[i - 1] + sequence[i - 2]  )

      return sequence[n]
def 			SCREAMING_SNAKE_CASE_			(							__A    :			int  )			->			int:
   _SCREAMING_SNAKE_CASE	=				0
   _SCREAMING_SNAKE_CASE	=				2

   while digits < n:
      index += 1
      _SCREAMING_SNAKE_CASE	=				len(str(fibonacci(__A  )  )  )

   return index
def 			SCREAMING_SNAKE_CASE_			(							__A    :			int = 10_00  )			->			int:
   return fibonacci_digits_index(__A  )


if __name__ == "__main__":
 print(solution(int(str(input()).strip())))

