a
    hx                     @   s   d dl Z ddlmZmZmZmZmZ g Zg dZdd e	e
eh d D Zdd	 Zd
d Zdd Zdd Zdd eD Zdd eD Ze	e Ze	e Zdd Zdd ZdS )    N   )_map_mt_args_kwargs_masks_match_tensors_match_wrap_resultis_masked_tensor)$addatan2Zarctan2Zbitwise_andZ
bitwise_orZbitwise_xorZbitwise_left_shiftZbitwise_right_shiftdivdivideZfloor_dividefmod	logaddexp
logaddexp2mulmultiply	nextafter	remaindersubsubtractZtrue_divideeqnelegeZgreaterZgreater_equalgtZ
less_equalltlessmaximumminimumfmaxfmin	not_equalc                 C   s   g | ]}|d  qS )_ ).0nr"   r"   \/var/www/html/assistant/venv/lib/python3.9/site-packages/torch/masked/maskedtensor/binary.py
<listcomp>8   s   r&   >   equalr   r   r   r   r   r   c                 C   sB   t | st |stdt| |s*tdt | r:|  S | S )Nz2At least one of `a` and `b` must be a MaskedTensorz a and b must have matching masks)r   	TypeErrorr   
ValueErrorget_mask)abr"   r"   r%   _get_at_least_one_maskK   s    
r-   c                 C   s\  t |dkrtd|dd  D ]}t|r tdq t|d d  sPtdt||dd \}}t||dd \}}|d j}	t|d	 st|d	 o|	|d	 jk}
|	tj	krN|
rt
|d  |d	  std
|d  |d	  krtd|d	  |d	< |d  }|d  }|d  |d< | | }t|||}n|	tjkr|
rt
|d  |d	  rt
|d  |d	  std|d	  |d	< |d  }|d  }|d  }|d  |d< | | }t||||}n| | }|r(|d ||d  |d S t|d d  }|	tjkrN||}t||S d S )Nr   zlen(kwargs) must equal 0   zRMaskedTensor binary ops do not support Tensor arguments aside from the lhs and rhszUInput masks must match. If you need support for this, please open an issue on Github.c                 S   s   |   S N)get_dataxr"   r"   r%   <lambda>c       z _binary_helper.<locals>.<lambda>c                 S   s   |   S r/   )r*   r1   r"   r"   r%   r3   d   r4   r   z\sparse_coo indices must match. If you need support for this, please open an issue on Github.z?input1 and input2 must have the same size for binary functions.z\sparse_csr indices must match. If you need support for this, please open an issue on Github.)lenr)   torchZ	is_tensorr(   r   r   Zlayoutr   Z
sparse_coor   indicessizevaluesZsparse_coo_tensorZ
sparse_csrZcrow_indicesZcol_indicesZsparse_csr_tensorZ_set_data_maskr-   ZstridedZ	expand_asr   )fnargskwargsinplacer+   Z	data_argsZ_data_kwargsZ	mask_argsZ_mask_kwargsZargs0_layoutZsame_layoutir8   vZresult_dataZcrowcolZresult_maskr"   r"   r%   _binary_helperU   sx    


rA   c                    s   t tjj|   fdd}|S )Nc                     s   t  | |ddS )NFr=   rA   r;   r<   r:   r"   r%   	binary_fn   s    z _torch_binary.<locals>.binary_fngetattrr6   opsatenfn_namerF   r"   rE   r%   _torch_binary   s    rM   c                    s   t tjj|   fdd}|S )Nc                     s   t  | |ddS )NTrB   rC   rD   rE   r"   r%   rF      s    z(_torch_inplace_binary.<locals>.binary_fnrG   rK   r"   rE   r%   _torch_inplace_binary   s    rN   c                 C   s    i | ]}t tjj|t|qS r"   )rH   r6   rI   rJ   rM   r#   namer"   r"   r%   
<dictcomp>   s   rQ   c                 C   s    i | ]}t tjj|t|qS r"   )rH   r6   rI   rJ   rN   rO   r"   r"   r%   rQ      s   c                 C   s   | t v p| tv S r/   )NATIVE_BINARY_FNSNATIVE_INPLACE_BINARY_FNSrE   r"   r"   r%   _is_native_binary   s    rT   c                 O   s8   | t v rt|  |i |S | tv r4t|  |i |S tS r/   )rR   NATIVE_BINARY_MAPrS   NATIVE_INPLACE_BINARY_MAPNotImplemented)r:   r;   r<   r"   r"   r%   _apply_native_binary   s
    rX   )r6   corer   r   r   r   r   __all__ZBINARY_NAMESlistsetZINPLACE_BINARY_NAMESr-   rA   rM   rN   rU   rV   keysrR   rS   rT   rX   r"   r"   r"   r%   <module>   s0   	'
L		