o
    i e	                     @   sf   d Z ddlZddlZddlZddlmZ ddlmZ ddlmZ ddlm	Z	 ddlm
Z
 d
dd	ZdS )z,Utility ops shared across tf.contrib.signal.    N)ops)tensor_util)	array_ops)math_ops)
while_loopc                 C   s  t |d| |gy t | } t |}| jd |jd | jjs+td| j |jjs6td|j t	| }t	|}|durd|durdt
jjdk rRtj}ntj}t |||W  d   S dd }d	d }tj||| |gd
d\} }| W  d   S 1 sw   Y  dS )az  Returns the greatest common divisor via Euclid's algorithm.

  Args:
    a: The dividend. A scalar integer `Tensor`.
    b: The divisor. A scalar integer `Tensor`.
    name: An optional name for the operation.

  Returns:
    A scalar `Tensor` representing the greatest common divisor between `a` and
    `b`.

  Raises:
    ValueError: If `a` or `b` are not scalar integers.
  gcdr   z"a must be an integer type. Got: %sz"b must be an integer type. Got: %sN   c                 S   s   t |t|S N)r   greaterr   
zeros_like)_b r   T/var/www/myenv/lib/python3.10/site-packages/tensorflow/python/ops/signal/util_ops.py<lambda>B   s    zgcd.<locals>.<lambda>c                 S   s   |t | |gS r	   )r   mod)ar   r   r   r   r   C   s    F)	back_prop)r   
name_scopeconvert_to_tensorshapeassert_has_rankdtype
is_integer
ValueErrorr   constant_valuesysversion_infomajor	fractionsr   mathr   )r   r   nameconst_aconst_bmath_gcdcondbodyr   r   r   r      s,   



$r   r	   )__doc__r   r    r   tensorflow.python.frameworkr   r   tensorflow.python.opsr   r   r   r   r   r   r   r   <module>   s   