�
J�g� � �P � d Z ddlZddlmZ ddlmZ ddlZddlm Z m
Z
ddlmZm
Z
mZ dd lmZmZmZmZmZ dd
lmZ ddlmZmZ d� Zd7d�Zd� Zd� Zd
d�d�Zddd�d�Z eej dg eeddd�� � g eeddd�� � g eeddd�� � e
dh� � g e
h d�� � gd e
dh� � gdgdg e
ddh� � gd� d� � � d!ddddddd"�d#�� � Z!d!ddd$dd%�d&�Z"dd'�d(�Z#d8d)�Z$d9d*�Z%d9d+�Z&d:d,�Z'd-� Z( d8d.�Z)d/� Z*d;d2�Z+d8d3�Z,dd4�d5�Z-d6� Z.dS )<zEUtilities to perform optimal mathematical operations in scikit-learn.� N)�partial)�Integral)�linalg�sparse� )�Interval�
StrOptions�validate_params� )�_average�_is_numpy_namespace�_nanmean�device�
get_namespace)�
csr_row_norms)�check_array�check_random_statec �� � t j | d�� � } t j | j t j � � rt j dt � � t j | | � � S )a` Squared Euclidean or Frobenius norm of x.
Faster than norm(x) ** 2.
Parameters
----------
x : array-like
The input array which could be either be a vector or a 2 dimensional array.
Returns
-------
float
The Euclidean norm when x is a vector, the Frobenius norm when x
is a matrix (2-d array).
�K)�orderzYArray type is integer, np.dot may overflow. Data should be float type to avoid this issue) �np�ravel�
issubdtype�dtype�integer�warnings�warn�UserWarning�dot��xs �e/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/sklearn/utils/extmath.py�squared_normr# sa � � ���#����A� �}�Q�W�b�j�)�)�
��
�@�
�
�
�
� �6�!�Q�<�<�� Fc �� � t j | � � r:| � � � } t | � � }|st j |� � }n�t
| � � \ }}t |� � r@t j | � � } t j d| | � � }|� |� � }n+|�
|� | | � � d�� � }|s|� |� � }|S )a� Row-wise (squared) Euclidean norm of X.
Equivalent to np.sqrt((X * X).sum(axis=1)), but also supports sparse
matrices and does not create an X.shape-sized temporary.
Performs no input validation.
Parameters
----------
X : array-like
The input array.
squared : bool, default=False
If True, return squared norms.
Returns
-------
array-like
The row-wise (squared) Euclidean norm of X.
zij,ij->ir ��axis)r �issparse�tocsrr r �sqrtr r
�asarray�einsum�sum�multiply)�X�squared�norms�xp�_s r"