
    `i                     z    U d dl Z d dlZd dlZd dlmZ d dD             Zi Zeed<   d Z	d Z
dd
Zd Zd ZddZdS )    N	get_dtypec                 ,    g | ]}t          |          S  r   .0xs     o/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/cupyx/scipy/sparse/_sputils.py
<listcomp>r      s0     @ @ @QIaLL @ @ @    )singledoublecsinglecdouble_upcast_memoc                 6    t          | t          j                  S N)
isinstancecupyndarrayr	   s    r
   isdenser      s    a&&&r   c                 ^    t          j        |           pt          |           o
| j        dk    S )z8Is x either a scalar, an array scalar, or a 0-dim array?r   )r   isscalarr   ndimr   s    r
   isscalarliker      s(    =;

 :qv{;r   r   Fc                 p   t          j        t           j                  j        }t          j        t           j                  j        }t           j        }|||k    rt           j        }t          | t           j                  r| f} | D ]}t          j        |          }t          j	        |j
        t           j                  su|re|j        dk    rHt          j        |j
        t           j                  r5|                                }|                                }||k    r||k    rt           j        } n|S )a  Based on input (integer) arrays ``a``, determines a suitable index data
    type that can hold the data in the arrays.

    Args:
        arrays (tuple of array_like):
            Input arrays whose types/contents to check
        maxval (float, optional):
            Maximum value needed
        check_contents (bool, optional):
            Whether to check the values in the arrays and not just their types.
            Default: False (check only the types)

    Returns:
        dtype: Suitable index data type (int32 or int64)
    Nr   )r   iinfoint32minmaxint64r   r   asarraycan_castdtypesize
issubdtypeinteger)arraysmaxvalcheck_contentsint32minint32maxr%   arrminvals           r
   get_index_dtyper0      s   " z$*%%)Hz$*%%)HJEHJE&$,''   l3}SY
33 	 	!8q==_SY== ! WWYYF WWYYF))f.@.@ JEE	 Lr   c                 b   | t          | t                    rt          d          t          |           }t	          j        t	          j        |          t          j                  s(t          d                    |j	                            d| cxk    rdk    sn t          d          d S d S )NzlTuples are not accepted for the 'axis' parameter. Please pass in one of the following: {-2, -1, 0, 1, None}.z#axis must be an integer, not {name})name   zaxis out of range)r   tuple	TypeErrortyper   r'   r%   r(   format__name__
ValueError)axis	axis_types     r
   validateaxisr=   F   s    
 dE"" 	B @ B B B JJ	 tz)44dlCC 	>A#V);V<<> > > da0111' $  r   c                      t                               |           }||S t          j        |  }t          D ]%}t          j        ||          r|t           | <   |c S &t          d|           )am  Returns the nearest supported sparse dtype for the
    combination of one or more types.

    upcast(t0, t1, ..., tn) -> T  where T is a supported dtype

    Examples:
        >>> upcast('int32')
        <type 'numpy.int32'>
        >>> upcast('int32','float32')
        <type 'numpy.float64'>
        >>> upcast('bool',float)
        <type 'numpy.complex128'>
    Nz#no supported conversion for types: )r   getnumpyresult_typesupported_dtypesr   r$   r6   )argstupcasts      r
   rE   rE   ]   s     	A}%F  =## 	!"LHHH	 )ttE
F
FFr   c                    t          |           dk    rt          d          t          |           dk    r[	 t          | d                   }t          d |D                       }nD# t          $ r t	          j        | d                   f}Y nw xY wt          d | D                       }|Kt          |          dk    rt          d          |d         dk     s|d         dk     rt          d	          nDt          j        |          }d
 t          |          D             }t          |          dk    r>t          j        |          }||k    r#t          d
                    ||                    nt          |          dk    r|d         }t          j        |d|         ||dz   d         z             }t          ||          \  }	}
|
dk    r<t          d |D                       }t          d
                    ||                    |d|         |	fz   ||dz   d         z   }nt          d          t          |          dk    rt          d          |S )zCheck validity of the shaper   z8function missing 1 required positional argument: 'shape'r4   c              3   >   K   | ]}t          j        |          V  d S r   operatorindexr   args     r
   	<genexpr>zcheck_shape.<locals>.<genexpr>   s,      HHchnS11HHHHHHr   c              3   >   K   | ]}t          j        |          V  d S r   rH   rK   s     r
   rM   zcheck_shape.<locals>.<genexpr>   s,      >>#(.-->>>>>>r   N   z,shape must be a 2-tuple of positive integersz#'shape' elements cannot be negativec                 $    g | ]\  }}|d k     |S )r   r   )r   ir	   s      r
   r   zcheck_shape.<locals>.<listcomp>   s!    HHH$!Q!a%%A%%%r   z,cannot reshape array of size {} into shape{}c              3   *   K   | ]}|d k     rdn|V  dS )r   newshapeNr   r   s     r
   rM   zcheck_shape.<locals>.<genexpr>   s.      !O!Oq1uu**!!O!O!O!O!O!Or   z&can only specify one unknown dimensionz$matrix shape must be two-dimensional)lenr6   iterr5   rI   rJ   r:   r@   prod	enumerater8   divmod)rC   current_shape
shape_iter	new_shapecurrent_sizenegative_indexesnew_sizeskip	specifiedunspecified	remainder	err_shapes               r
   check_shaperd   z   s    4yyA~~ " # # 	# 
Ta	Id1gJ HHZHHHHHII  	4 	4 	4!Q003III	4
 >>>>>>>	y>>QKLLLq\A1!1!1BCCC "2 z-00HH)I*>*>HHH  A%%z),,H<''  "&&,f\9&E&EG G G ( !""a''#A&D
9QtV#4ya7I#IJJI%+L)%D%D"KA~~!!O!OY!O!O!OOO	  "&&,f\9&E&EG G G!!D&)[N:YtAvww=OOIIEFFF
9~~?@@@s   A& &%BB)r   NFr   )r   rI   r@   cupy._core._dtyper   rB   r   dict__annotations__r   r   r0   r=   rE   rd   r   r   r
   <module>rh      s       ' ' ' ' ' '@ @>@ @ @  d   ' ' '< < <
- - - -`2 2 2.G G G:/ / / / / /r   