
    AVh                         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 Zej                  Zej                  Z	ej                  Zd Zd	 Zy
)zrPrivate convenience functions for RaggedTensors.

None of these methods are exposed in the main "ragged" package.
    )	array_ops)	check_ops)control_flow_ops)gen_ragged_math_ops)math_opsc                     d}| D ]'  }t        |      t        | d         k7  st        |       | dd D cg c]1  }t        | d   |      D ]  \  }}t        j                  |||       3 c}}}S c c}}}w )a7  Checks that the given splits lists are identical.

  Performs static tests to ensure that the given splits lists are identical,
  and returns a list of control dependency op tensors that check that they are
  fully identical.

  Args:
    nested_splits_lists: A list of nested_splits_lists, where each split_list is
      a list of `splits` tensors from a `RaggedTensor`, ordered from outermost
      ragged dimension to innermost ragged dimension.

  Returns:
    A list of control dependency op tensors.
  Raises:
    ValueError: If the splits are not identical.
  z(Inputs must have identical ragged splitsr      Nmessage)len
ValueErrorzipr   assert_equal)nested_splits_lists	error_msgsplits_lists1s2s        X/home/dcms/DCMS/lib/python3.12/site-packages/tensorflow/python/ops/ragged/ragged_util.pyassert_splits_matchr      s    " 9)( "k
;321566y!!"
 -QR0
 

-a0+>
 2r RY7
7
  
s   6A3c                 \    t        j                  dgt        j                  |       gd      S )z2Returns splits corresponding to the given lengths.r   axis)r   concatr   cumsum)lengthss    r   lengths_to_splitsr   =   s%    			A3 89	CC    c                    t        j                  |d      t        j                  |d|j                   d      g}t        j                  |d      t        j                  |d|j                   d      g}t	        j
                  ||      }t	        j
                  ||      }|j                  j                  dk7  r#t        |dd	 |d
      }t        |dd |d
      }n?t        ||d
      }t        j                  ||j                        d   }|d||z
   }||d }t        j                  d|j                        }	t        j                  |||	      }
t        j                  | |
j                        S )a  Repeats each range of `params` (as specified by `splits`) `repeats` times.

  Let the `i`th range of `params` be defined as
  `params[splits[i]:splits[i + 1]]`.  Then this function returns a tensor
  containing range 0 repeated `repeats[0]` times, followed by range 1 repeated
  `repeats[1]`, ..., followed by the last range repeated `repeats[-1]` times.

  Args:
    params: The `Tensor` whose values should be repeated.
    splits: A splits tensor indicating the ranges of `params` that should be
      repeated. Elements should be non-negative integers.
    repeats: The number of times each range should be repeated. Supports
      broadcasting from a scalar value. Elements should be non-negative
      integers.

  Returns:
    A `Tensor` with the same rank and type as `params`.

  #### Example:

  >>> print(repeat_ranges(
  ...     params=tf.constant(['a', 'b', 'c']),
  ...     splits=tf.constant([0, 2, 3]),
  ...     repeats=tf.constant(3)))
  tf.Tensor([b'a' b'b' b'a' b'b' b'a' b'b' b'c' b'c' b'c'],
      shape=(9,), dtype=string)
  z,Input argument 'splits' must be non-negativer
   z1Input argument 'splits' must be integer, but got z insteadz-Input argument 'repeats' must be non-negativez2Input argument 'repeats' must be integer, but got r   Nr   r   r	   )out_type )r   assert_non_negativeassert_integerdtyper   with_dependenciesshapendimsrepeatr   onesr   ragged_rangegatherrt_dense_values)paramssplitsrepeatssplits_checksrepeats_checksrepeated_startsrepeated_limitsrepeated_splitsn_splitsoneoffsetss              r   repeat_rangesr9   B   s}   < ##
H 
,,x)	- ##
J 
--*	. --mVD&..~wG' ]]AVCR[':OVABZq9O VW15OGJH%&9x''9:O%gh/O 	r?001#,,-'			&'"9"9	::r   N)__doc__tensorflow.python.opsr   r   r   r   r   r   get_positive_axisconvert_to_int_tensorrepeat_with_axisr)   r   r9   r"   r   r   <module>r?      sQ   
 , + 2 5 *: // !77 		#	#D
H;r   