




'''simple docstring'''

import math


def __UpperCAmelCase	(   _UpperCAmelCase		:   list		,				_UpperCAmelCase		:   int = 0		,				_UpperCAmelCase		:   int = 0						)      ->      list:
			__snake_case			=		end or len(_UpperCAmelCase						)
			for i in range(_UpperCAmelCase		,				_UpperCAmelCase						):
						__snake_case			=		i
						__snake_case			=		array[i]
						while temp_index != start and temp_index_value < array[temp_index - 1]:
									__snake_case			=		array[temp_index - 1]
									temp_index -= 1
						__snake_case			=		temp_index_value
			return array


def __UpperCAmelCase	(   _UpperCAmelCase		:   list		,				_UpperCAmelCase		:   int		,				_UpperCAmelCase		:   int						)      ->      None:  # Max Heap
			__snake_case			=		index
			__snake_case			=		2 * index + 1  # Left Node
			__snake_case			=		2 * index + 2  # Right Node

			if left_index < heap_size and array[largest] < array[left_index]:
						__snake_case			=		left_index

			if right_index < heap_size and array[largest] < array[right_index]:
						__snake_case			=		right_index

			if largest != index:
						__snake_case		,     __snake_case			=		array[largest], array[index]
						heapify(_UpperCAmelCase		,				_UpperCAmelCase		,				_UpperCAmelCase						)


def __UpperCAmelCase	(   _UpperCAmelCase		:   list						)      ->      list:
			__snake_case			=		len(_UpperCAmelCase						)

			for i in range(n // 2		,				-1		,				-1						):
						heapify(_UpperCAmelCase		,				_UpperCAmelCase		,				_UpperCAmelCase						)

			for i in range(n - 1		,				0		,				-1						):
						__snake_case		,     __snake_case			=		array[0], array[i]
						heapify(_UpperCAmelCase		,				0		,				_UpperCAmelCase						)

			return array


def __UpperCAmelCase	(   _UpperCAmelCase		:   list		,				_UpperCAmelCase		:   int		,				_UpperCAmelCase		:   int		,				_UpperCAmelCase		:   int						)      ->      int:
			if (array[first_index] > array[middle_index]) != (
			    array[first_index] > array[last_index]
			):
						return array[first_index]
			elif (array[middle_index] > array[first_index]) != (
			    array[middle_index] > array[last_index]
			):
						return array[middle_index]
			else:
						return array[last_index]


def __UpperCAmelCase	(   _UpperCAmelCase		:   list		,				_UpperCAmelCase		:   int		,				_UpperCAmelCase		:   int		,				_UpperCAmelCase		:   int						)      ->      int:
			__snake_case			=		low
			__snake_case			=		high
			while True:
						while array[i] < pivot:
									i += 1
						j -= 1
						while pivot < array[j]:
									j -= 1
						if i >= j:
									return i
						__snake_case		,     __snake_case			=		array[j], array[i]
						i += 1


def __UpperCAmelCase	(   _UpperCAmelCase		:   list						)      ->      list:
			if len(_UpperCAmelCase						) == 0:
						return array
			__snake_case			=		2 * math.ceil(math.loga(len(_UpperCAmelCase						)						)						)
			__snake_case			=		16
			return intro_sort(_UpperCAmelCase		,				0		,				len(_UpperCAmelCase						)		,				_UpperCAmelCase		,				_UpperCAmelCase						)


def __UpperCAmelCase	(   _UpperCAmelCase		:   list		,				_UpperCAmelCase		:   int		,				_UpperCAmelCase		:   int		,				_UpperCAmelCase		:   int		,				_UpperCAmelCase		:   int						)      ->      list:
			while end - start > size_threshold:
						if max_depth == 0:
									return heap_sort(_UpperCAmelCase						)
						max_depth -= 1
						__snake_case			=		median_of_a(_UpperCAmelCase		,				_UpperCAmelCase		,				start + ((end - start) // 2) + 1		,				end - 1						)
						__snake_case			=		partition(_UpperCAmelCase		,				_UpperCAmelCase		,				_UpperCAmelCase		,				_UpperCAmelCase						)
						intro_sort(_UpperCAmelCase		,				_UpperCAmelCase		,				_UpperCAmelCase		,				_UpperCAmelCase		,				_UpperCAmelCase						)
						__snake_case			=		p
			return insertion_sort(_UpperCAmelCase		,				_UpperCAmelCase		,				_UpperCAmelCase						)


if __name__ == "__main__":
						import doctest

						doctest.testmod()

						a       :						Dict								=		input('''Enter numbers separated by a comma : ''').strip()
						a       :						str								=		[float(item) for item in user_input.split(''',''')]
						print(sort(unsorted))










'''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 			a_	(				_lowerCAmelCase			,_lowerCAmelCase			,_lowerCAmelCase=1E-12			) -> List[Any]:
  __lowerCamelCase			:			int       			=					jnp.divide(emb_a.T			,jnp.clip(jnp.linalg.norm(_lowerCAmelCase			,axis=1			)			,a_min=_lowerCAmelCase			)			).T
  __lowerCamelCase			:			Tuple       			=					jnp.divide(emb_a.T			,jnp.clip(jnp.linalg.norm(_lowerCAmelCase			,axis=1			)			,a_min=_lowerCAmelCase			)			).T
  return jnp.matmul(_lowerCAmelCase			,norm_emb_a.T			)






class    lowerCamelCase_       (							nn.Module	):
  """simple docstring"""




  a_				   =42
  a_				   =jnp.floataa




  def 		_lowercase	(					self :      Optional[Any]  )   ->   Tuple:
    __lowerCamelCase			:			Optional[int]       			=					FlaxCLIPVisionModule(self.config.vision_config  )
    __lowerCamelCase			:			Any       			=					nn.Dense(self.config.projection_dim     ,      use_bias=_a     ,      dtype=self.dtype  )

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

    __lowerCamelCase			:			Optional[int]       			=					self.param('concept_embeds_weights'     ,      jax.nn.initializers.ones     ,      (17,)  )
    __lowerCamelCase			:			Dict       			=					self.param('special_care_embeds_weights'     ,      jax.nn.initializers.ones     ,      (3,)  )




  def __call__(					self :      Tuple     ,      _a :      Any  )   ->   Optional[int]:
    __lowerCamelCase			:			int       			=					self.vision_model(_a  )[1]
    __lowerCamelCase			:			Optional[int]       			=					self.visual_projection(_a  )

    __lowerCamelCase			:			Optional[Any]       			=					jax_cosine_distance(_a     ,      self.special_care_embeds  )
    __lowerCamelCase			:			Tuple       			=					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
    __lowerCamelCase			:			Dict       			=					0.0

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

    __lowerCamelCase			:			Optional[int]       			=					cos_dist - self.concept_embeds_weights[None, :] + special_adjustment
    __lowerCamelCase			:			List[str]       			=					jnp.round(_a     ,      3  )
    __lowerCamelCase			:			List[Any]       			=					jnp.any(concept_scores > 0     ,      axis=1  )

    return has_nsfw_concepts






class    lowerCamelCase_       (							SCREAMING_SNAKE_CASE_	):
  """simple docstring"""




  a_				   =CLIPConfig
  a_				   ="""clip_input"""
  a_				   =FlaxStableDiffusionSafetyCheckerModule




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




  def 		_lowercase	(					self :      int     ,      _a :      jax.random.KeyArray     ,      _a :      Tuple     ,      _a :      FrozenDict = None  )   ->   FrozenDict:
    # init input tensor
    __lowerCamelCase			:			Optional[int]       			=					jax.random.normal(_a     ,      _a  )

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

    __lowerCamelCase			:			Tuple       			=					self.module.init(_a     ,      _a  )['params']

    return random_params




  def __call__(					self :      Optional[int]     ,      _a :      int     ,      _a :      dict = None     ,      )   ->   Dict:
    __lowerCamelCase			:			str       			=					jnp.transpose(_a     ,      (0, 2, 3, 1)  )

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






