
    AVh`                        d 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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m Z m!Z! ddl"m#Z#  ejH                  dg d      Z% eddd      Z&d4de#e!e&f   de#e!ejN                  f   de(de(de)f
dZ*  ed       ejV                  e*            Z,de#e!e&f   de#e!ejN                  f   de(de(de)f
dZ- ejH                  dg d      Z. eddd      Z/d5de#e!e/f   de#e!ejN                  f   de)d e(fd!Z0  ed"       ejV                  e0            Z1de#e!e/f   de#e!ejN                  f   de)d e(fd#Z2 ejH                  d$d%d&g      Z3 ed'dd      Z4d6de#e!e4f   d(e#e!ejj                  f   d)e#e!ejN                  f   de#e!ejN                  f   d*e)d+e)d,e)fd-Z6  ed.       ejV                  e6            Z7de#e!e4f   d(e#e!ejj                  f   d)e#e!ejN                  f   de#e!ejN                  f   d*e)d+e)d,e)fd/Z8 ejH                  d0d%d&g      Z9d6de#e!ejt                  f   d(e#e!ejj                  f   d)e#e!ejN                  f   de#e!ejN                  f   d*e)d+e)d,e)fd1Z;  ed2       ejV                  e;            Z<de#e!ejt                  f   d(e#e!ejj                  f   d)e#e!ejN                  f   de#e!ejN                  f   d*e)d+e)d,e)fd3Z=y)7zUPython wrappers around TensorFlow ops.

This file is MACHINE GENERATED! Do not edit.
    N)
pywrap_tfe)context)core)execute)dtypes)annotation_types)op_def_registry)ops)op_def_library)deprecated_endpoints)dispatch)	tf_export)TypeVarListAny)	AnnotatedCTCBeamSearchDecoder)decoded_indicesdecoded_valuesdecoded_shapelog_probabilityTV_CTCBeamSearchDecoder_Tz_atypes.Float32z_atypes.Float64inputssequence_length
beam_width	top_pathsmerge_repeatedc                 T   t         j                   xs t        j                         }|j                  }|j                  r7	 t	        j
                  |d|| |d|d|d|      }t        j                  |      }|S t        j                   |d      }t        j                   |d      }|d}t        j"                  |d      }t%        j&                  d| |||||      \  }
}
}}|dd }t        j(                         rjd|j+                  d      d|j+                  d      d|j-                  d      d	|j/                  d	      f}|j0                  }t        j2                  d|||       |d| g||d z   }|dd
 |d
d
|z    gz   |d
|z   d z   }|dd |dd|z    gz   |d|z   d z   }t        j                  |      }|S # t        j                  $ r }	t        j                  |	|       Y d}	~	nd}	~	wt        j                  $ r Y nw xY w	 t        | ||||||      S # t        j                  $ r Y w xY w)a  Performs beam search decoding on the logits given in input.

  A note about the attribute merge_repeated: For the beam search decoder,
  this means that if consecutive entries in a beam are the same, only
  the first of these is emitted.  That is, when the top path is "A B B B B",
  "A B" is returned if merge_repeated = True but "A B B B B" is
  returned if merge_repeated = False.

  Args:
    inputs: A `Tensor`. Must be one of the following types: `float32`, `float64`.
      3-D, shape: `(max_time x batch_size x num_classes)`, the logits.
    sequence_length: A `Tensor` of type `int32`.
      A vector containing sequence lengths, size `(batch)`.
    beam_width: An `int` that is `>= 1`.
      A scalar >= 0 (beam search beam width).
    top_paths: An `int` that is `>= 1`.
      A scalar >= 0, <= beam_width (controls output size).
    merge_repeated: An optional `bool`. Defaults to `True`.
      If true, merge repeated classes in output.
    name: A name for the operation (optional).

  Returns:
    A tuple of `Tensor` objects (decoded_indices, decoded_values, decoded_shape, log_probability).

    decoded_indices: A list of `top_paths` `Tensor` objects with type `int64`.
    decoded_values: A list of `top_paths` `Tensor` objects with type `int64`.
    decoded_shape: A list of `top_paths` `Tensor` objects with type `int64`.
    log_probability: A `Tensor`. Has the same type as `inputs`.
  r   r   r   r   N)r   r   r   namectxT)r   r   r   r   r   r   T      )_contextr   _thread_local_datais_eagerr   TFE_Py_FastPathExecute_CTCBeamSearchDecoderOutput_make_core_NotOkStatusException_opsraise_from_not_ok_status_FallbackException&ctc_beam_search_decoder_eager_fallback_SymbolicException_executemake_int	make_bool_op_def_library_apply_op_helpermust_record_gradient_get_attr_int_get_attr_bool_get_attr_typer   record_gradient)r   r   r   r   r   r   _ctxtld_resulte__op_outputs_attrs_inputs_flats                  Q/home/dcms/DCMS/lib/python3.12/site-packages/tensorflow/python/ops/gen_ctc_ops.pyctc_beam_search_decoderrE      sm   < 
			0h..0$#\\
11$dFOj+y:Jg ,11':gn   \:*	;7)N%%n6FG.'88v0?+5/=D	J!QX
 QK'""$C--l;[,.>  !12C  %'F ::Lfg?Zi !GIJ$77'BQK71Q]344wq9}~7NN'BQK71Q]344wq9}~7NN''--g6'	.E && -
##At,,## 
3
/jI'd> > ## 
s0    5F3 3G:G!!G:9G:>H H'&H'zraw_ops.CTCBeamSearchDecoderc                    t        j                  |d      }t        j                  |d      }|d}t        j                  |d      }t        j                  | g|t        j
                  t        j                  gt        j
                        \  }\  } t        j                  |t        j                        }| |g}d|d|d|d|f}	t        j                  d||z   |z   dz   ||	||      }
t        j                         rt        j                  d	||	|
       |
d | g|
|d  z   }
|
d d |
dd|z    gz   |
d|z   d  z   }
|
d d
 |
d
d
|z    gz   |
d
|z   d  z   }
t        j                  |
      }
|
S )Nr   r   Tr   r!   s   CTCBeamSearchDecoderr"   r   attrsr    r   r   r#   )r1   r2   r3   args_to_matching_eager_dtypesfloat32float64r,   convert_to_tensorint32r   r6   r:   r(   r)   )r   r   r   r   r   r   r    _attr_TrC   rB   r=   s              rD   r/   r/   n   s     \:*	;7)N%%n6FG.66xwX_XgXgFjlsl{l{|'9F**?GMMJ//*,*k9NC2&4i)6K&7')*7+3?v!$41' ""$fg?Zi !GIJ$77'BQK71Q]344wq9}~7NN'BQK71Q]344wq9}~7NN''--g6'	.    CTCGreedyDecoderTV_CTCGreedyDecoder_Tblank_indexc                    t         j                   xs t        j                         }|j                  }|j                  r5	 t	        j
                  |d|| |d|d|	      }t        j                  |      }|S |d}t        j                   |d      }|d}t        j"                  |d      }t%        j&                  d| ||||      \  }	}	}
}|dd }t        j(                         rYd|
j+                  d      d|
j-                  d      d	|
j/                  d	      f}|
j0                  }t        j2                  d|||       t        j                  |      }|S # t        j                  $ r }t        j                  ||       Y d}~nd}~wt        j                  $ r Y nw xY w	 t        | |||||      S # t        j                  $ r Y Ow xY w)
a7  Performs greedy decoding on the logits given in inputs.

  A note about the attribute merge_repeated: if enabled, when
  consecutive logits' maximum indices are the same, only the first of
  these is emitted.  Labeling the blank '*', the sequence "A B B * B B"
  becomes "A B B" if merge_repeated = True and "A B B B B" if
  merge_repeated = False.

  Regardless of the value of merge_repeated, if the maximum index of a given
  time and batch corresponds to the blank, index `(num_classes - 1)`, no new
  element is emitted.

  Args:
    inputs: A `Tensor`. Must be one of the following types: `float32`, `float64`.
      3-D, shape: `(max_time x batch_size x num_classes)`, the logits.
    sequence_length: A `Tensor` of type `int32`.
      A vector containing sequence lengths, size `(batch_size)`.
    merge_repeated: An optional `bool`. Defaults to `False`.
      If True, merge repeated classes in output.
    blank_index: An optional `int`. Defaults to `-1`.
    name: A name for the operation (optional).

  Returns:
    A tuple of `Tensor` objects (decoded_indices, decoded_values, decoded_shape, log_probability).

    decoded_indices: A `Tensor` of type `int64`.
    decoded_values: A `Tensor` of type `int64`.
    decoded_shape: A `Tensor` of type `int64`.
    log_probability: A `Tensor`. Has the same type as `inputs`.
  rQ   r   rS   N)r   rS   r   r    F)r   r   r   rS   r   r!   )r$   r   r%   r&   r   r'   _CTCGreedyDecoderOutputr)   r*   r+   r,   r-   r.   !ctc_greedy_decoder_eager_fallbackr0   r1   r3   r2   r4   r5   r6   r8   r7   r9   r   r:   )r   r   r   rS   r   r;   r<   r=   r>   r?   r@   rA   rB   rC   s                 rD   ctc_greedy_decoderrX      s   > 
			0h..0$#\\	11 $.-Fg (--g6gn N%%n6FG.K!!+}=+'886?+9(3$@!QX QK'""$ 2 23C DS..}=s  %'F ::LL&';#))'2'	.= && -
##At,,## 
.
/.!$8 8 ## 
s0    3E F$E??FFF- -GGzraw_ops.CTCGreedyDecoderc                    |d}t        j                  |d      }|d}t        j                  |d      }t        j                  | g|t        j
                  t        j                  gt        j
                        \  }\  } t        j                  |t        j                        }| |g}d|d|d|f}t        j                  dd||||      }	t        j                         rt        j                  d	|||	       t        j                  |	      }	|	S )
NFr   rU   rS   r!   s   CTCGreedyDecoder   rG   rQ   )r1   r3   r2   rI   rJ   rK   rL   r,   rM   rN   r   r6   r:   rV   r)   )
r   r   r   rS   r   r    rO   rC   rB   r=   s
             rD   rW   rW      s    N%%n6FG.K!!+}=+66xwX_XgXgFjlsl{l{|'9F**?GMMJ//*,nm[#	&0!L#)s?'""$L&';#))'2'	.rP   CTCLosslossgradientTV_CTCLoss_Tlabels_indiceslabels_valuespreprocess_collapse_repeatedctc_merge_repeated!ignore_longer_outputs_than_inputsc                    t         j                   xs t        j                         }|j                  }	|	j                  r9	 t	        j
                  |d|| |||d|d|d|      }
t        j                  |
      }
|
S |d}t        j                   |d      }|d}t        j                   |d      }|d}t        j                   |d      }t#        j$                  d| |||||||		      \  }}}}|dd }
t        j&                         rjd|j)                  d      d|j)                  d      d|j)                  d      d
|j+                  d
      f}|j,                  }t        j.                  d|||
       t        j                  |
      }
|
S # t        j                  $ r }t        j                  ||       Y d}~nd}~wt        j                  $ r Y nw xY w	 t        | ||||||||	      S # t        j                  $ r Y w xY w)a  Calculates the CTC Loss (log probability) for each batch entry.  Also calculates

  the gradient.  This class performs the softmax operation for you, so inputs
  should be e.g. linear projections of outputs by an LSTM.

  Args:
    inputs: A `Tensor`. Must be one of the following types: `float32`, `float64`.
      3-D, shape: `(max_time x batch_size x num_classes)`, the logits.
    labels_indices: A `Tensor` of type `int64`.
      The indices of a `SparseTensor<int32, 2>`.
      `labels_indices(i, :) == [b, t]` means `labels_values(i)` stores the id for
      `(batch b, time t)`.
    labels_values: A `Tensor` of type `int32`.
      The values (labels) associated with the given batch and time.
    sequence_length: A `Tensor` of type `int32`.
      A vector containing sequence lengths (batch).
    preprocess_collapse_repeated: An optional `bool`. Defaults to `False`.
      Scalar, if true then repeated labels are
      collapsed prior to the CTC calculation.
    ctc_merge_repeated: An optional `bool`. Defaults to `True`.
      Scalar.  If set to false, *during* CTC calculation
      repeated non-blank labels will not be merged and are interpreted as
      individual labels.  This is a simplified version of CTC.
    ignore_longer_outputs_than_inputs: An optional `bool`. Defaults to `False`.
      Scalar. If set to true, during CTC
      calculation, items that have longer output sequences than input sequences
      are skipped: they don't contribute to the loss term and have zero-gradient.
    name: A name for the operation (optional).

  Returns:
    A tuple of `Tensor` objects (loss, gradient).

    loss: A `Tensor`. Has the same type as `inputs`.
    gradient: A `Tensor`. Has the same type as `inputs`.
  r[   ra   rb   rc   Nra   rb   rc   r   r    FTr   r_   r`   r   ra   rb   rc   r   r!   )r$   r   r%   r&   r   r'   _CTCLossOutputr)   r*   r+   r,   r-   r.   ctc_loss_eager_fallbackr0   r1   r3   r4   r5   r6   r8   r9   r   r:   r   r_   r`   r   ra   rb   rc   r   r;   r<   r=   r>   r?   r@   rA   rB   rC   s                    rD   ctc_lossrj      s2   H 
			0h..0$#\\11iv~}7$&:?)+g $$W-gn ")#( !)!3!34PRp!q))*<>RS&.(-%&.&8&89Z\  'A#'88&!.#20L&85V!QX QK'""$,  !?@"C$6$67K$L1  !DEs  %'F ::L<2  )'	.W && -
##At,,## 
$
.-'C/,M  ## 
s0    7F G
F11G
	G
G" "G98G9zraw_ops.CTCLossc	                    |d}t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d      }t        j                  | g|t        j                  t        j
                  gt        j                        \  }	\  } t        j                  |t        j                        }t        j                  |t        j                        }t        j                  |t        j                        }| |||g}
d|d|d|d|	f}t        j                  dd|
|||	      }t        j                         rt        j                  d
|
||       t        j                  |      }|S )NFra   Trb   rc   r!   s   CTCLossr#   rG   r[   )r1   r3   rI   rJ   rK   rL   r,   rM   int64rN   r   r6   r:   rg   r)   )r   r_   r`   r   ra   rb   rc   r   r    rO   rC   rB   r=   s                rD   rh   rh   R  sc   !)#( !)!3!34PRp!q))*<>RS&.(-%&.&8&89Z\  'A#66xwX_XgXgFjlsl{l{|'9F)).'--H.((F-**?GMMJ/.-I,*,H*%'H#	& Z<v!$41'""$<2  )'	.rP   	CTCLossV2c                    t         j                   xs t        j                         }|j                  }	|	j                  r9	 t	        j
                  |d|| |||d|d|d|      }
t        j                  |
      }
|
S |d}t        j                   |d      }|d}t        j                   |d      }|d}t        j                   |d      }t#        j$                  d| |||||||		      \  }}}}|dd }
t        j&                         rYd|j)                  d      d|j)                  d      d|j)                  d      f}|j*                  }t        j,                  d|||
       t        j                  |
      }
|
S # t        j                  $ r }t        j                  ||       Y d}~nd}~wt        j                  $ r Y nw xY w	 t        | ||||||||	      S # t        j                  $ r Y ow xY w)
a  Calculates the CTC Loss (log probability) for each batch entry.  Also calculates

  the gradient.  This class performs the softmax operation for you, so inputs
  should be e.g. linear projections of outputs by an LSTM.

  Args:
    inputs: A `Tensor` of type `float32`.
      3-D, shape: `(max_time x batch_size x num_classes)`, the logits. Default blank
      label is 0 rather num_classes - 1.
    labels_indices: A `Tensor` of type `int64`.
      The indices of a `SparseTensor<int32, 2>`.
      `labels_indices(i, :) == [b, t]` means `labels_values(i)` stores the id for
      `(batch b, time t)`.
    labels_values: A `Tensor` of type `int32`.
      The values (labels) associated with the given batch and time.
    sequence_length: A `Tensor` of type `int32`.
      A vector containing sequence lengths (batch).
    preprocess_collapse_repeated: An optional `bool`. Defaults to `False`.
      Scalar, if true then repeated labels are
      collapsed prior to the CTC calculation.
    ctc_merge_repeated: An optional `bool`. Defaults to `True`.
      Scalar.  If set to false, *during* CTC calculation
      repeated non-blank labels will not be merged and are interpreted as
      individual labels.  This is a simplified version of CTC.
    ignore_longer_outputs_than_inputs: An optional `bool`. Defaults to `False`.
      Scalar. If set to true, during CTC
      calculation, items that have longer output sequences than input sequences
      are skipped: they don't contribute to the loss term and have zero-gradient.
    name: A name for the operation (optional).

  Returns:
    A tuple of `Tensor` objects (loss, gradient).

    loss: A `Tensor` of type `float32`.
    gradient: A `Tensor` of type `float32`.
  rm   ra   rb   rc   Nre   FTrf   )r$   r   r%   r&   r   r'   _CTCLossV2Outputr)   r*   r+   r,   r-   r.   ctc_loss_v2_eager_fallbackr0   r1   r3   r4   r5   r6   r8   r   r:   ri   s                    rD   ctc_loss_v2rq   r  s#   J 
			0h..0$#\\11k47$&:?)+g !&&w/gn ")#( !)!3!34PRp!q))*<>RS&.(-%&.&8&89Z\  'A#'88F>#0%42N(:7X !QX QK'""$,  !?@"C$6$67K$L1  !DE	GF
 ::L\674""7+'	.U && -
##At,,## 
'
.-'C/,M  ## 
s0    7E2 2F9F  F98F9=G G('G(zraw_ops.CTCLossV2c	                    |d}t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d      }t        j                  | t        j
                        } t        j                  |t        j                        }t        j                  |t        j                        }t        j                  |t        j                        }| |||g}	d|d|d|f}
t        j                  dd|	|
||      }t        j                         rt        j                  d	|	|
|       t        j                  |      }|S )
NFra   Trb   rc   s	   CTCLossV2r#   rG   rm   )r1   r3   r,   rM   rJ   rK   rl   rN   r   r6   r:   ro   r)   )r   r_   r`   r   ra   rb   rc   r   r    rC   rB   r=   s               rD   rp   rp     s?   !)#( !)!3!34PRp!q))*<>RS&.(-%&.&8&89Z\  'A#!!&'//:&)).'--H.((F-**?GMMJ/.-I,*,H*%'HJ& \1\#)s?'""$\674""7+'	.rP   )TN)FrU   N)FTFN)>__doc__collectionstensorflow.pythonr   tensorflow.python.eagerr   r$   r   r*   r   r1   tensorflow.python.frameworkr   rJ   tensorflow.security.fuzzing.pyr   _atypesr	   _op_def_registryr
   r,   r   r4   "tensorflow.python.util.deprecationr   tensorflow.python.utilr   	_dispatch tensorflow.python.util.tf_exportr   typingr   r   r   typing_extensionsr   
namedtupler(   r   Int32intboolrE   	to_raw_opr   r/   rV   rR   rX   rQ   rW   rg   r^   Int64rj   r[   rh   ro   Float32rq   rm   rp    rP   rD   <module>r      s  
  6 7 1 7 9 F K 3 I C 8 6 % % '4k44MO 
 $$?ARTef JIc3L.L$M J`ijmovo|o|j|`} J  LO J  \_ J  pt JX Ay!?@PgAhi 9SB[=[3\ oxy|  F  L  L  zL  pM   [^   kn   @D . 1+00MO 
   79JL]^ Fy.C)CD FW`adfmfsfsasWt F  FJ F  ^a FP 9978HZ9[\ i=R8R.S fopsu|  vC  vC  qC  gD   VZ   il ( (''Z
 ~'8:KL[YsL01 [9SRYR_R_M_C` [qz{~  AH  AN  AN  |N  rO [  bk  lo  qx  q~  q~  l~  b [  ^b [  }A [  jn [z ')%
&~t~~h'?
@Ic<.?$@ R[\_ahanan\nRo   AJ  KN  PW  P]  P]  K]  A^   qz  {~  @G  @M  @M  {M  qN   nr   HL   qu 6 *;))Z 
[	#w"67 [SVX_XeXeSeIf [  xA  BE  GN  GT  GT  BT  xU [  hq  ru  w~  wD  wD  rD  hE [  dh [  CG [  pt [z +I)*>4>>++FG	ygoo1E'F XabegngtgtbtXu   GP  QT  V]  Vc  Vc  Qc  Gd   w@  AD  FM  FS  FS  AS  wT   tx   NR   w{ rP   