


"""simple docstring"""





from typing import TYPE_CHECKING

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


snake_case__						:   int			 = {
    '''configuration_canine''': ['''CANINE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''CanineConfig'''],
    '''tokenization_canine''': ['''CanineTokenizer'''],
}

try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 snake_case__						:   str			 = [
     '''CANINE_PRETRAINED_MODEL_ARCHIVE_LIST''',
     '''CanineForMultipleChoice''',
     '''CanineForQuestionAnswering''',
     '''CanineForSequenceClassification''',
     '''CanineForTokenClassification''',
     '''CanineLayer''',
     '''CanineModel''',
     '''CaninePreTrainedModel''',
     '''load_tf_weights_in_canine''',
 ]


if TYPE_CHECKING:
 from .configuration_canine import CANINE_PRETRAINED_CONFIG_ARCHIVE_MAP, CanineConfig
 from .tokenization_canine import CanineTokenizer

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_canine import (
      CANINE_PRETRAINED_MODEL_ARCHIVE_LIST,
      CanineForMultipleChoice,
      CanineForQuestionAnswering,
      CanineForSequenceClassification,
      CanineForTokenClassification,
      CanineLayer,
      CanineModel,
      CaninePreTrainedModel,
      load_tf_weights_in_canine,
  )


else:
 import sys

 snake_case__						:   Optional[Any]			 = _LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)






"""simple docstring"""





from __future__ import annotations

import math

import numpy as np
from numpy.linalg import norm


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


def    _snake_case  (  _snake_case :	np.ndarray       ,      _snake_case :	np.ndarray	):

      if dataset.ndim != value_array.ndim:
            lowerCAmelCase    :		List[Any]				=      (
                '''Wrong input data\'s dimensions... '''
                f'''dataset : {dataset.ndim}, value_array : {value_array.ndim}'''
            )
            raise ValueError(_snake_case	)

      try:
            if dataset.shape[1] != value_array.shape[1]:
                  lowerCAmelCase    :		Dict				=      (
                      '''Wrong input data\'s shape... '''
                      f'''dataset : {dataset.shape[1]}, value_array : {value_array.shape[1]}'''
                  )
                  raise ValueError(_snake_case	)
      except IndexError:
            if dataset.ndim != value_array.ndim:
                  raise TypeError('''Wrong shape'''	)

      if dataset.dtype != value_array.dtype:
            lowerCAmelCase    :		Optional[Any]				=      (
                '''Input data have different datatype... '''
                f'''dataset : {dataset.dtype}, value_array : {value_array.dtype}'''
            )
            raise TypeError(_snake_case	)

      lowerCAmelCase    :		str				=      []

      for value in value_array:
            lowerCAmelCase    :		int				=      euclidean(_snake_case       ,      dataset[0]	)
            lowerCAmelCase    :		Union[str, Any]				=      dataset[0].tolist()

            for dataset_value in dataset[1:]:
                  lowerCAmelCase    :		Any				=      euclidean(_snake_case       ,      _snake_case	)

                  if dist > temp_dist:
                        lowerCAmelCase    :		List[Any]				=      temp_dist
                        lowerCAmelCase    :		Tuple				=      dataset_value.tolist()

            answer.append([vector, dist]	)

      return answer


def    _snake_case  (  _snake_case :	np.ndarray       ,      _snake_case :	np.ndarray	):
      return np.dot(_snake_case       ,      _snake_case	) / (norm(_snake_case	) * norm(_snake_case	))


if __name__ == "__main__":
 import doctest

 doctest.testmod()


