"""simple docstring"""






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

from ...utils import logging


__lowerCAmelCase					: Optional[int]        =logging.get_logger(__name__)


def     UpperCAmelCase__ (       lowerCAmelCase__  :Any      ,	lowerCAmelCase__  :Union[str, Any]	)				->					Optional[int]:
      '''simple docstring'''


      lowercase														=			nn.functional.normalize(lowerCAmelCase__	)
      lowercase														=			nn.functional.normalize(lowerCAmelCase__	)
      return torch.mm(lowerCAmelCase__      ,	normalized_text_embeds.t()	)






class 				_A		( lowerCAmelCase			):
      snake_case__    :     List[Any]													=			CLIPConfig

      snake_case__    :     List[str]													=			['CLIPEncoderLayer']

      def __init__(		self	, __lowerCAmelCase		):







            """simple docstring"""



            super().__init__(__lowerCAmelCase		)

            lowercase														=			CLIPVisionModel(config.vision_config		)
            lowercase														=			nn.Linear(config.vision_config.hidden_size	, config.projection_dim	, bias=__lowerCAmelCase		)

            lowercase														=			nn.Parameter(torch.ones(17	, config.projection_dim		)	, requires_grad=__lowerCAmelCase		)
            lowercase														=			nn.Parameter(torch.ones(3	, config.projection_dim		)	, requires_grad=__lowerCAmelCase		)

            lowercase														=			nn.Parameter(torch.ones(17		)	, requires_grad=__lowerCAmelCase		)
            lowercase														=			nn.Parameter(torch.ones(3		)	, requires_grad=__lowerCAmelCase		)

      @torch.no_grad()
      def        A__ (		self	, __lowerCAmelCase	, __lowerCAmelCase		):







            """simple docstring"""



            lowercase														=			self.vision_model(__lowerCAmelCase		)[1]  # pooled_output
            lowercase														=			self.visual_projection(__lowerCAmelCase		)

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

            lowercase														=			[]
            lowercase														=			image_embeds.shape[0]
            for i in range(__lowerCAmelCase		):
                  lowercase														=			{"""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
                  lowercase														=			0.0

                  for concept_idx in range(len(special_cos_dist[0]		)		):
                        lowercase														=			special_cos_dist[i][concept_idx]
                        lowercase														=			self.special_care_embeds_weights[concept_idx].item()
                        lowercase														=			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]}		)
                              lowercase														=			0.0_1

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

                  result.append(__lowerCAmelCase		)

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

            return images, has_nsfw_concepts







      @torch.no_grad()
      def        A__ (		self	, __lowerCAmelCase	, __lowerCAmelCase		):







            """simple docstring"""



            lowercase														=			self.vision_model(__lowerCAmelCase		)[1]  # pooled_output
            lowercase														=			self.visual_projection(__lowerCAmelCase		)

            lowercase														=			cosine_distance(__lowerCAmelCase	, self.special_care_embeds		)
            lowercase														=			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
            lowercase														=			0.0

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

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

            return images, has_nsfw_concepts




"""simple docstring"""






from __future__ import annotations

import math


def     UpperCAmelCase__ (       lowerCAmelCase__  :int	)				->					list[int]:
      '''simple docstring'''


      if num <= 0:
            lowercase														=			f'{num}: Invalid input, please enter a positive integer.'
            raise ValueError(lowerCAmelCase__	)

      lowercase														=			[True] * (num + 1)
      lowercase														=			[]
      lowercase														=			2
      lowercase														=			int(math.sqrt(lowerCAmelCase__	)	)

      while start <= end:
            # If start is a prime
            if sieve[start] is True:
                  prime.append(lowerCAmelCase__	)

                  # Set multiples of start be False
                  for i in range(start * start      ,	num + 1      ,	lowerCAmelCase__	):
                        if sieve[i] is True:
                              lowercase														=			False

            start += 1

      for j in range(end + 1      ,	num + 1	):
            if sieve[j] is True:
                  prime.append(lowerCAmelCase__	)

      return prime


if __name__ == "__main__":
       print(prime_sieve(int(input("""Enter a positive integer: """).strip())))



