


'''simple docstring'''







from __future__ import annotations

import math

import numpy as np
from numpy.linalg import norm


def 	SCREAMING_SNAKE_CASE_					(  _UpperCAmelCase	:	np.ndarray    ,_UpperCAmelCase	:	np.ndarray  )  ->			float:
       return math.sqrt(sum(pow(a - b    ,2  ) for a, b in zip(_UpperCAmelCase    ,_UpperCAmelCase  )  )  )


def 	SCREAMING_SNAKE_CASE_					(  _UpperCAmelCase	:	np.ndarray    ,_UpperCAmelCase	:	np.ndarray  )  ->			list[list[list[float] | float]]:

       if dataset.ndim != value_array.ndim:
              _a    : int     					=(
                  """Wrong input data's dimensions... """
                  F"dataset : {dataset.ndim}, value_array : {value_array.ndim}"
              )
              raise ValueError(_UpperCAmelCase  )

       try:
              if dataset.shape[1] != value_array.shape[1]:
                     _a    : Optional[Any]     					=(
                         """Wrong input data's shape... """
                         F"dataset : {dataset.shape[1]}, value_array : {value_array.shape[1]}"
                     )
                     raise ValueError(_UpperCAmelCase  )
       except IndexError:
              if dataset.ndim != value_array.ndim:
                     raise TypeError("""Wrong shape"""  )

       if dataset.dtype != value_array.dtype:
              _a    : Tuple     					=(
                  """Input data have different datatype... """
                  F"dataset : {dataset.dtype}, value_array : {value_array.dtype}"
              )
              raise TypeError(_UpperCAmelCase  )

       _a    : Dict     					=[]

       for value in value_array:
              _a    : Optional[int]     					=euclidean(_UpperCAmelCase    ,dataset[0]  )
              _a    : List[Any]     					=dataset[0].tolist()

              for dataset_value in dataset[1:]:
                     _a    : Any     					=euclidean(_UpperCAmelCase    ,_UpperCAmelCase  )

                     if dist > temp_dist:
                            _a    : Any     					=temp_dist
                            _a    : int     					=dataset_value.tolist()

              answer.append([vector, dist]  )

       return answer


def 	SCREAMING_SNAKE_CASE_					(  _UpperCAmelCase	:	np.ndarray    ,_UpperCAmelCase	:	np.ndarray  )  ->			float:
       return np.dot(_UpperCAmelCase    ,_UpperCAmelCase  ) / (norm(_UpperCAmelCase  ) * norm(_UpperCAmelCase  ))


if __name__ == "__main__":
   import doctest

   doctest.testmod()






'''simple docstring'''







from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


A__:    List[str]					    =       {
    '''configuration_chinese_clip''': [
        '''CHINESE_CLIP_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''ChineseCLIPConfig''',
        '''ChineseCLIPOnnxConfig''',
        '''ChineseCLIPTextConfig''',
        '''ChineseCLIPVisionConfig''',
    ],
    '''processing_chinese_clip''': ['''ChineseCLIPProcessor'''],
}

try:
   if not is_vision_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   A__:    Optional[int]					    =       ['''ChineseCLIPFeatureExtractor''']
   A__:    Any					    =       ['''ChineseCLIPImageProcessor''']

try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   A__:    Dict					    =       [
       '''CHINESE_CLIP_PRETRAINED_MODEL_ARCHIVE_LIST''',
       '''ChineseCLIPModel''',
       '''ChineseCLIPPreTrainedModel''',
       '''ChineseCLIPTextModel''',
       '''ChineseCLIPVisionModel''',
   ]

if TYPE_CHECKING:
   from .configuration_chinese_clip import (
       CHINESE_CLIP_PRETRAINED_CONFIG_ARCHIVE_MAP,
       ChineseCLIPConfig,
       ChineseCLIPOnnxConfig,
       ChineseCLIPTextConfig,
       ChineseCLIPVisionConfig,
   )
   from .processing_chinese_clip import ChineseCLIPProcessor

   try:
      if not is_vision_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .feature_extraction_chinese_clip import ChineseCLIPFeatureExtractor, ChineseCLIPImageProcessor

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_chinese_clip import (
          CHINESE_CLIP_PRETRAINED_MODEL_ARCHIVE_LIST,
          ChineseCLIPModel,
          ChineseCLIPPreTrainedModel,
          ChineseCLIPTextModel,
          ChineseCLIPVisionModel,
      )

else:
   import sys

   A__:    str					    =       _LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)


