
    AVhn                     ^   d 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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lmZ ddlmZ  ej$                  ej&                        ddej(                  fd       Z ej$                  ej*                        	 	 	 ddej(                  fd       Zy)z#Operator Squeeze for RaggedTensors.    )constant_op)dtypes)ops)tensor)	array_ops)control_flow_assert)control_flow_ops)math_ops)ragged_tensor)RaggedTensor)deprecation)dispatchNinputc                 $   t        j                  |d| g      5  t        j                  |       } t	        | t
        j                        r t        j                  | ||      cddd       S |t        d      t	        |t              r|g}n3t	        |t        t        f      rt        d |D              st        d      g }g }t        |      D cg c]4  \  }}t        j                   || j"                  j$                  d|z  d      6 }}}|D ]A  }|| j&                  kD  r|j)                  || j&                  z
         1|j)                  |       C g }t+        j,                  d| j.                  j0                  	      }	t        | j3                               D ]`  \  }}
|dz   |v s|j)                  t5        j6                  t9        j:                  t9        j<                  |
|	            d
|dz   z  g             b d|v r|t+        j,                  dt>        j@                  	      }|j)                  t5        j6                  t9        j<                  t        jB                  | j.                        |      dg             d}tE        jF                  || jH                        }|rt        j                  ||      }g }t               }t        | jJ                        D ]  \  }}|dz   |vs|j)                  |         |rd|v r|jM                  d       tO        jP                  ||      }tS        tU        d| j&                  dz               jW                  tS        |            rt        j                  |dg|      }|cddd       S c c}}w # 1 sw Y   yxY w)aH  Ragged compatible squeeze.

  If `input` is a `tf.Tensor`, then this calls `tf.squeeze`.

  If `input` is a `tf.RaggedTensor`, then this operation takes `O(N)` time,
  where `N` is the number of elements in the squeezed dimensions.

  Args:
    input: A potentially ragged tensor. The input to squeeze.
    axis: An optional list of ints. Defaults to `None`. If the `input` is
      ragged, it only squeezes the dimensions listed. It fails if `input` is
      ragged and axis is []. If `input` is not ragged it calls tf.squeeze. Note
      that it is an error to squeeze a dimension that is not 1. It must be in
      the range of [-rank(input), rank(input)).
   name: A name for the operation (optional).

  Returns:
    A potentially ragged tensor. Contains the same data as input,
    but has one or more dimensions of size 1 removed.
  RaggedSqueezeNz*Ragged.squeeze must have an axis argument.c              3   <   K   | ]  }t        |t                y w)N)
isinstanceint).0ds     ^/home/dcms/DCMS/lib/python3.12/site-packages/tensorflow/python/ops/ragged/ragged_squeeze_op.py	<genexpr>zsqueeze.<locals>.<genexpr>?   s     4!:a%4s   z)Axis must be a list or tuple of integers.zaxis[%d]zrank(input)   )dtypez-the given axis (axis = %d) is not squeezable!r      z,the given axis (axis = 0) is not squeezable!),r   
name_scoper   "convert_to_tensor_or_ragged_tensorr   r   Tensorr   squeeze
ValueErrorr   listtupleall	TypeError	enumerateget_positive_axisshapendimsragged_rankappendr   constant
row_splitsr   nested_row_lengthsr   Assertr
   
reduce_allequalr   int32sizer	   with_dependenciesflat_valuesnested_row_splitspopr   from_nested_row_splitssetrangeissubset)r   axisname
dense_dimsragged_dimsir   dimassertion_listscalar_tensor_onerscalar_tensor_twosqueezed_rtremaining_row_splits	row_splits                  r   r   r      sV   , ~~dOeW5 F<<UCE%'udD1F F
 |CDD$Vd$u.4t44ABBJK @I7;q! 	##Au{{'8'8*q.$1	3D    	u  	 # 1 1123	  N#,,Qe6F6F6L6LM%2245 N1	
Q+	&&##HNN16G$HI@AEJKM	NN 	K%..qE

$
$nn..!1!124EG=>@A K"44^5:5F5FHK %%k:>k6!%"9"9: /9
a%	###I./
 [ 0q!55k6JLK
 5E%%)*+44S5EF%%kA3=kMF F !F Fs4   AN)A&N9N BN%D=N#BN NNc                 L    t        j                  d|d|      }t        | ||      S )Nr;   squeeze_dims)r   deprecated_argument_lookupr   )r   r;   r<   rI   s       r   _ragged_squeeze_v1rK   ~   s,    
 
	/	/n0<
>$	d	##    )NN)NNN)__doc__tensorflow.python.frameworkr   r   r   r   tensorflow.python.opsr   r   r	   r
   tensorflow.python.ops.raggedr   *tensorflow.python.ops.ragged.ragged_tensorr   tensorflow.python.utilr   r   dispatch_for_api
squeeze_v2Raggedr   rK    rL   r   <module>rW      s    * 3 . + . + 5 2 * 6 C . + 9//0[='' [ 1[| 9,,-  $($m22 $ .$rL   