
    AVh             +       2   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dd      Z&dpde#e!e&f   de#e!e&f   de#e!e&f   de#e!e&f   de'de'de'de(d e)d!e)d"e*fd#Z+  ed$       ejX                  e+            Z-de#e!e&f   de#e!e&f   de#e!e&f   de#e!e&f   de'de'de'de(d e)d!e)d"e*fd%Z. ejH                  d&g d'      Z/ ed(dddd      Z0dqde#e!e0f   de#e!e0f   de#e!e0f   de#e!e0f   d)e#e!e0f   d*e#e!e0f   d+e#e!e0f   d,e#e!e0f   d-e#e!e0f   d.e#e!e0f   d/e#e!e0f   de'de'de'de(d e)d!e)f"d0Z1  ed1       ejX                  e1            Z2de#e!e0f   de#e!e0f   de#e!e0f   de#e!e0f   d)e#e!e0f   d*e#e!e0f   d+e#e!e0f   d,e#e!e0f   d-e#e!e0f   d.e#e!e0f   d/e#e!e0f   de'de'de'de(d e)d!e)f"d2Z3 ejH                  d3g d'      Z4 ed4dddd      Z5dqde#e!e5f   de#e!e5f   de#e!e5f   de#e!e5f   d)e#e!e5f   d*e#e!e5f   d+e#e!e5f   d,e#e!e5f   d-e#e!e5f   d.e#e!e5f   d/e#e!e5f   d5e#e!ejl                  f   de'de'de'de(d e)d!e)f$d6Z7  ed7       ejX                  e7            Z8de#e!e5f   de#e!e5f   de#e!e5f   de#e!e5f   d)e#e!e5f   d*e#e!e5f   d+e#e!e5f   d,e#e!e5f   d-e#e!e5f   d.e#e!e5f   d/e#e!e5f   d5e#e!ejl                  f   de'de'de'de(d e)d!e)f$d8Z9 ejH                  d9g d'      Z: ed:dddd      Z;drde#e!e;f   de#e!e;f   de#e!e;f   de#e!e;f   d;e#e!ejx                  f   d)e#e!e;f   d*e#e!e;f   d+e#e!e;f   d,e#e!e;f   d-e#e!e;f   d.e#e!e;f   d/e#e!e;f   d5e#e!ejl                  f   de'de'de'de(d e)d!e)d<e)d=e*f*d>Z=  ed?       ejX                  e=            Z>de#e!e;f   de#e!e;f   de#e!e;f   de#e!e;f   d;e#e!ejx                  f   d)e#e!e;f   d*e#e!e;f   d+e#e!e;f   d,e#e!e;f   d-e#e!e;f   d.e#e!e;f   d/e#e!e;f   d5e#e!ejl                  f   de'de'de'de(d e)d!e)d<e)d=e*f*d@Z? edAdddd      Z@dqdBe#e!ejx                  f   dCe#e!ejx                  f   dDe#e!ejx                  f   dEe#e e!   e@f   dFe#e e!   e@f   de'de'de'de(d e)d!e)dGe#e!e@f   fdHZA  edI       ejX                  eA            ZBdBe#e!ejx                  f   dCe#e!ejx                  f   dDe#e!ejx                  f   dEe#e e!   e@f   dFe#e e!   e@f   de'de'de'de(d e)d!e)dGe#e!e@f   fdJZC edKdddd      ZDdsdBe#e!ejx                  f   dCe#e!ejx                  f   dDe#e!ejx                  f   dEe#e e!   eDf   dFe#e e!   eDf   de'de'de'de(d e)d!e)d<e)dGe#e!eDf   fdLZE  edM       ejX                  eE            ZFdBe#e!ejx                  f   dCe#e!ejx                  f   dDe#e!ejx                  f   dEe#e e!   eDf   dFe#e e!   eDf   de'de'de'de(d e)d!e)d<e)dGe#e!eDf   fdNZG edOdddd      ZH edPdQdR      ZIdsdBe#e!ejx                  f   dCe#e!ejx                  f   dDe#e!ejx                  f   dSeHdTeIde'de'de'de(d e)d!e)d<e)dGe#e!eIf   fdUZJ  edV       ejX                  eJ            ZKdBe#e!ejx                  f   dCe#e!ejx                  f   dDe#e!ejx                  f   dSeHdTeIde'de'de'de(d e)d!e)d<e)dGe#e!eIf   fdWZL ejH                  dXdEdFg      ZM edYdddd      ZNdqdBe#e!ejx                  f   dCe#e!ejx                  f   dDe#e!ejx                  f   de#e!eNf   dZe)de'de'de'de(d e)d!e)fd[ZO  ed\       ejX                  eO            ZPdBe#e!ejx                  f   dCe#e!ejx                  f   dDe#e!ejx                  f   de#e!eNf   dZe)de'de'de'de(d e)d!e)fd]ZQ ejH                  d^dEdFg      ZR ed_dddd      ZSdsdBe#e!ejx                  f   dCe#e!ejx                  f   dDe#e!ejx                  f   de#e!eSf   d`e)dae)de'de'de'de(d e)d!e)d<e)fdbZT  edc       ejX                  eT            ZUdBe#e!ejx                  f   dCe#e!ejx                  f   dDe#e!ejx                  f   de#e!eSf   d`e)dae)de'de'de'de(d e)d!e)d<e)fddZV ejH                  deg df      ZW edgdddd      ZXdpde#e!eXf   de#e!eXf   de#e!eXf   de#e!eXf   de'de'de'de(d e)d!e)d"e*fdhZY  edi       ejX                  eY            ZZde#e!eXf   de#e!eXf   de#e!eXf   de#e!eXf   de'de'de'de(d e)d!e)d"e*fdjZ[ ejH                  dkg df      Z\ edldddd      Z]dtde#e!e]f   de#e!e]f   de#e!e]f   de#e!e]f   d;e#e!ejx                  f   de'de'de'de(d e)d!e)d<e)d"e*d=e*fdmZ^  edn       ejX                  e^            Z_de#e!e]f   de#e!e]f   de#e!e]f   de#e!e]f   d;e#e!ejx                  f   de'de'de'de(d e)d!e)d<e)d"e*d=e*fdoZ`y)uzUPython 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CudnnRNN)outputoutput_houtput_creserve_spaceTV_CudnnRNN_Tz_atypes.BFloat16z_atypes.Float32z_atypes.Float64z_atypes.Halfinputinput_hinput_cparamsrnn_mode
input_mode	directiondropoutseedseed2is_trainingc                 p   t         j                   xs t        j                         }|j                  }|j                  rA	 t	        j
                  |d|| |||d|d|d|d|d|d|	d|
      }t        j                  |      }|S |d}t        j                   |d      }|d}t        j                   |d      }|d}t        j                   |d      }|d}t        j"                  |d      }|d}t        j$                  |d      }|	d}	t        j$                  |	d      }	|
d}
t        j&                  |
d      }
t)        j*                  d| |||||||||	|
|      \  }}}}|d	d	 }t        j,                         rd|j/                  d      d|j1                  d      d|j1                  d      d|j1                  d      d|j1                  d      d|j3                  d      d|j3                  d      d|j5                  d      f}|j6                  }t        j8                  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 4w xY w)a  A RNN backed by cuDNN.

  Computes the RNN from the input and initial states, with respect to the params
  buffer.

  rnn_mode: Indicates the type of the RNN model.
  input_mode: Indicate whether there is a linear projection between the input and
    the actual computation before the first layer. 'skip_input' is only allowed
    when input_size == num_units; 'auto_select' implies 'skip_input' when
    input_size == num_units; otherwise, it implies 'linear_input'.
  direction: Indicates whether a bidirectional model will be used. Should be
    "unidirectional" or "bidirectional".
  dropout: Dropout probability. When set to 0., dropout is disabled.
  seed: The 1st part of a seed to initialize dropout.
  seed2: The 2nd part of a seed to initialize dropout.
  input: A 3-D tensor with the shape of [seq_length, batch_size, input_size].
  input_h: A 3-D tensor with the shape of [num_layer * dir, batch_size,
      num_units].
  input_c: For LSTM, a 3-D tensor with the shape of
      [num_layer * dir, batch, num_units]. For other models, it is ignored.
  params: A 1-D tensor that contains the weights and biases in an opaque layout.
      The size must be created through CudnnRNNParamsSize, and initialized
      separately. Note that they might not be compatible across different
      generations. So it is a good idea to save and restore
  output: A 3-D tensor with the shape of [seq_length, batch_size,
      dir * num_units].
  output_h: The same shape has input_h.
  output_c: The same shape as input_c for LSTM. An empty tensor for other models.
  is_training: Indicates whether this operation is used for inference or
    training.
  reserve_space: An opaque tensor that can be used in backprop calculation. It
    is only produced if is_training is false.

  Args:
    input: A `Tensor`. Must be one of the following types: `bfloat16`, `half`, `float32`, `float64`.
    input_h: A `Tensor`. Must have the same type as `input`.
    input_c: A `Tensor`. Must have the same type as `input`.
    params: A `Tensor`. Must have the same type as `input`.
    rnn_mode: An optional `string` from: `"rnn_relu", "rnn_tanh", "lstm", "gru"`. Defaults to `"lstm"`.
    input_mode: An optional `string` from: `"linear_input", "skip_input", "auto_select"`. Defaults to `"linear_input"`.
    direction: An optional `string` from: `"unidirectional", "bidirectional"`. Defaults to `"unidirectional"`.
    dropout: An optional `float`. Defaults to `0`.
    seed: An optional `int`. Defaults to `0`.
    seed2: An optional `int`. Defaults to `0`.
    is_training: An optional `bool`. Defaults to `True`.
    name: A name for the operation (optional).

  Returns:
    A tuple of `Tensor` objects (output, output_h, output_c, reserve_space).

    output: A `Tensor`. Has the same type as `input`.
    output_h: A `Tensor`. Has the same type as `input`.
    output_c: A `Tensor`. Has the same type as `input`.
    reserve_space: A `Tensor`. Has the same type as `input`.
  r   r   r   r   r    r!   r"   r#   N	r   r   r   r    r!   r"   r#   namectxlstmlinear_inputunidirectionalr   Tr   r   r   r   r   r   r   r    r!   r"   r#   r&   T)_contextr   _thread_local_datais_eagerr   TFE_Py_FastPathExecute_CudnnRNNOutput_make_core_NotOkStatusException_opsraise_from_not_ok_status_FallbackExceptioncudnn_rnn_eager_fallback_SymbolicException_executemake_str
make_floatmake_int	make_bool_op_def_library_apply_op_helpermust_record_gradient_get_attr_typeget_attr_get_attr_int_get_attr_boolinputsrecord_gradientr   r   r   r   r   r   r   r    r!   r"   r#   r&   _ctxtld_resulte__op_outputs_attrs_inputs_flats                        W/home/dcms/DCMS/lib/python3.12/site-packages/tensorflow/python/ops/gen_cudnn_rnn_ops.py	cudnn_rnnrS      s   p 
			0h..0$#\\
11j$w,
KIw}kKg  %%g.gn Hx4(J  \:* I	;7)_G3'	\D			4	($
]E


E7
+%K"";>+'88%'!H't[t	E!QX
 QK'""$3%%c*Jll:&ll<(+ll;'CLL4Kc''/(-  /1F ::LL&'3!!'*'	.i && -
##At,,## 
%
'6H9g5k	 
 ## 
0    ?H; ;JI))JJJ J54J5zraw_ops.CudnnRNNc                    |d}t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d	      }|	d}	t        j                  |	d
      }	|
d}
t        j                  |
d      }
t        j
                  | |||g|t        j                  t        j                  t        j                  t        j                  g      \  }}|\  } }}}| |||g}d|d|d|d|d|d	|d
|	d|
f}t        j                  dd||||      }t        j                         rt        j                  d|||       t        j                  |      }|S )Nr(   r   r)   r   r*   r   r   r    r!   r"   Tr#   r,   s   CudnnRNN   rF   attrsr'   r&   r   )r:   r;   r<   r=   r>   args_to_matching_eager_dtypesbfloat16halffloat32float64r   rA   rG   r1   r2   r   r   r   r   r   r   r   r    r!   r"   r#   r&   r'   _attr_T	_inputs_TrQ   rP   rK   s                     rR   r8   r8      s   Hx4(J  \:* I	;7)_G3'	\D			4	($
]E


E7
+%K"";>+66wQW7XZ]`g`p`pryr~r~  AH  AP  AP  RY  Ra  Ra  `d  e'9&/#5'7F'62,*hjy)WfdGU& [!L#)s?'""$L&'3!!'*'	.    CudnnRNNBackprop)input_backpropinput_h_backpropinput_c_backpropparams_backpropTV_CudnnRNNBackprop_Tr   r   r   output_backpropoutput_h_backpropoutput_c_backpropr   c                    t         j                   xs t        j                         }|j                  }|j                  rF	 t	        j
                  |d|| |||||||||	|
d|d|d|d|d|d|      }t        j                  |      }|S |d
}t        j                   |d      }|d}t        j                   |d      }|d}t        j                   |d      }|d}t        j"                  |d      }|d}t        j$                  |d      }|d}t        j$                  |d      }t'        j(                  	 di d| d|d|d|d|d|d|d|d|d|	d|
d|d|d|d|d|d|d|\  }}}}|dd }t        j*                         rd|j-                  d      d|j/                  d      d|j/                  d      d|j/                  d      d|j/                  d      d|j1                  d      d|j1                  d      f}|j2                  }t        j4                  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 7w xY w)ah  Backprop step of CudnnRNN.

  Compute the backprop of both data and weights in a RNN.

  rnn_mode: Indicates the type of the RNN model.
  input_mode: Indicate whether there is a linear projection between the input and
      the actual computation before the first layer. 'skip_input' is only allowed
      when input_size == num_units; 'auto_select' implies 'skip_input' when
      input_size == num_units; otherwise, it implies 'linear_input'.
  direction: Indicates whether a bidirectional model will be used. Should be
    "unidirectional" or "bidirectional".
  dropout: Dropout probability. When set to 0., dropout is disabled.
  seed: The 1st part of a seed to initialize dropout.
  seed2: The 2nd part of a seed to initialize dropout.
  input: A 3-D tensor with the shape of [seq_length, batch_size, input_size].
  input_h: A 3-D tensor with the shape of [num_layer * dir, batch_size,
      num_units].
  input_c: For LSTM, a 3-D tensor with the shape of
      [num_layer * dir, batch, num_units]. For other models, it is ignored.
  params: A 1-D tensor that contains the weights and biases in an opaque layout.
      The size must be created through CudnnRNNParamsSize, and initialized
      separately. Note that they might not be compatible across different
      generations. So it is a good idea to save and restore
  output: A 3-D tensor with the shape of [seq_length, batch_size,
      dir * num_units].
  output_h: The same shape has input_h.
  output_c: The same shape as input_c for LSTM. An empty tensor for other models.
  output_backprop: A 3-D tensor with the same shape as output in the forward pass.
  output_h_backprop: A 3-D tensor with the same shape as output_h in the forward
      pass.
  output_c_backprop: A 3-D tensor with the same shape as output_c in the forward
      pass.
  reserve_space: The same reserve_space produced in for forward operation.
  input_backprop: The backprop to input in the forward pass. Has the same shape
      as input.
  input_h_backprop: The backprop to input_h in the forward pass. Has the same
      shape as input_h.
  input_c_backprop: The backprop to input_c in the forward pass. Has the same
      shape as input_c.
  params_backprop: The backprop to the params buffer in the forward pass. Has the
      same shape as params.

  Args:
    input: A `Tensor`. Must be one of the following types: `bfloat16`, `half`, `float32`, `float64`.
    input_h: A `Tensor`. Must have the same type as `input`.
    input_c: A `Tensor`. Must have the same type as `input`.
    params: A `Tensor`. Must have the same type as `input`.
    output: A `Tensor`. Must have the same type as `input`.
    output_h: A `Tensor`. Must have the same type as `input`.
    output_c: A `Tensor`. Must have the same type as `input`.
    output_backprop: A `Tensor`. Must have the same type as `input`.
    output_h_backprop: A `Tensor`. Must have the same type as `input`.
    output_c_backprop: A `Tensor`. Must have the same type as `input`.
    reserve_space: A `Tensor`. Must have the same type as `input`.
    rnn_mode: An optional `string` from: `"rnn_relu", "rnn_tanh", "lstm", "gru"`. Defaults to `"lstm"`.
    input_mode: An optional `string` from: `"linear_input", "skip_input", "auto_select"`. Defaults to `"linear_input"`.
    direction: An optional `string` from: `"unidirectional", "bidirectional"`. Defaults to `"unidirectional"`.
    dropout: An optional `float`. Defaults to `0`.
    seed: An optional `int`. Defaults to `0`.
    seed2: An optional `int`. Defaults to `0`.
    name: A name for the operation (optional).

  Returns:
    A tuple of `Tensor` objects (input_backprop, input_h_backprop, input_c_backprop, params_backprop).

    input_backprop: A `Tensor`. Has the same type as `input`.
    input_h_backprop: A `Tensor`. Has the same type as `input`.
    input_c_backprop: A `Tensor`. Has the same type as `input`.
    params_backprop: A `Tensor`. Has the same type as `input`.
  rc   r   r   r   r    r!   r"   Nr   r   r   r    r!   r"   r&   r'   r(   r)   r*   r   r   r   r   r   r   r   r   ri   rj   rk   r   r&   r,   )rc   )r-   r   r.   r/   r   r0   _CudnnRNNBackpropOutputr2   r3   r4   r5   r6   r7   !cudnn_rnn_backprop_eager_fallbackr9   r:   r;   r<   r=   r?   r@   rA   rB   rC   rD   rF   rG   )r   r   r   r   r   r   r   ri   rj   rk   r   r   r   r   r    r!   r"   r&   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   s                              rR   cudnn_rnn_backproprp      s`   N 
			0h..0$#\\11 $w(O5F=*hKIwg (--g6gn Hx4(J  \:* I	;7)_G3'	\D			4	($
]E


E7
+%'88
'"'
'18
'BI
'#)
'28
'CK
' &.
' -<	
'
 /@
' /@
' +8
' CK
' (2
' >G
' %,
' 37
' ?D
' "&
'!QX QK'""$3%%c*Jll:&ll<(+ll;'CLL4Kc''/(*F ::LL&';#))'2'	.o && -
##At,,## 
.
'668X
,.?
(zwT  ## 
s1    AH= =JI++JJJ& &J=<J=zraw_ops.CudnnRNNBackpropc                    |d}t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d	      }|d}t        j                  |d
      }t        j                  | |||||||||	|
g|t
        j                  t
        j                  t
        j                  t
        j                  g      \  }}|\  } }}}}}}}}}	}
| |||||||||	|
g}d|d|d|d|d|d	|d
|f}t        j                  dd||||      }t        j                         rt        j                  d|||       t        j                  |      }|S )Nr(   r   r)   r   r*   r   r   r    r!   r"   r,   s   CudnnRNNBackproprV   rW   rc   )r:   r;   r<   r=   rY   rZ   r[   r\   r]   r^   r   rA   rG   rn   r2   )r   r   r   r   r   r   r   ri   rj   rk   r   r   r   r   r    r!   r"   r&   r'   r`   ra   rQ   rP   rK   s                           rR   ro   ro   T  s)   Hx4(J  \:* I	;7)_G3'	\D			4	($
]E


E7
+%66wQWY_aiks  vE  GX  Zk  mz  8{  }@  CJ  CS  CS  U\  Ua  Ua  cj  cr  cr  t{  tC  tC  BF  G'9 IR  F5'7FFHhQbdu  xE'668X`q  tE  GT  U,*hjy)WfdGUL&0!L#)s?'""$L&';#))'2'	.rb   CudnnRNNBackpropV2TV_CudnnRNNBackpropV2_Thost_reservedc                    t         j                   xs t        j                         }|j                  }|j                  rG	 t	        j
                  |d|| |||||||||	|
|d|d|d|d|d|d|      }t        j                  |      }|S |d
}t        j                   |d      }|d}t        j                   |d      }|d}t        j                   |d      }|d}t        j"                  |d      }|d}t        j$                  |d      }|d}t        j$                  |d      }t'        j(                  	 di d| d|d|d|d|d|d|d|d|d|	d|
d|d|d|d|d|d|d|d|\  }}}}|dd }t        j*                         rd|j-                  d      d|j/                  d      d|j/                  d      d|j/                  d      d|j/                  d      d|j1                  d      d|j1                  d      f}|j2                  }t        j4                  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)am  Backprop step of CudnnRNN.

  Compute the backprop of both data and weights in a RNN. Takes an extra
      "host_reserved" inupt than CudnnRNNBackprop, which is used to determine RNN
      cudnnRNNAlgo_t and cudnnMathType_t.

  rnn_mode: Indicates the type of the RNN model.
  input_mode: Indicates whether there is a linear projection between the input and
      the actual computation before the first layer. 'skip_input' is only allowed
      when input_size == num_units; 'auto_select' implies 'skip_input' when
      input_size == num_units; otherwise, it implies 'linear_input'.
  direction: Indicates whether a bidirectional model will be used. Should be
    "unidirectional" or "bidirectional".
  dropout: Dropout probability. When set to 0., dropout is disabled.
  seed: The 1st part of a seed to initialize dropout.
  seed2: The 2nd part of a seed to initialize dropout.
  input: A 3-D tensor with the shape of [seq_length, batch_size, input_size].
  input_h: A 3-D tensor with the shape of [num_layer * dir, batch_size,
      num_units].
  input_c: For LSTM, a 3-D tensor with the shape of
      [num_layer * dir, batch, num_units]. For other models, it is ignored.
  params: A 1-D tensor that contains the weights and biases in an opaque layout.
      The size must be created through CudnnRNNParamsSize, and initialized
      separately. Note that they might not be compatible across different
      generations. So it is a good idea to save and restore
  output: A 3-D tensor with the shape of [seq_length, batch_size,
      dir * num_units].
  output_h: The same shape has input_h.
  output_c: The same shape as input_c for LSTM. An empty tensor for other models.
  output_backprop: A 3-D tensor with the same shape as output in the forward pass.
  output_h_backprop: A 3-D tensor with the same shape as output_h in the forward
      pass.
  output_c_backprop: A 3-D tensor with the same shape as output_c in the forward
      pass.
  reserve_space: The same reserve_space produced in the forward operation.
  host_reserved: The same host_reserved produced in the forward operation.
  input_backprop: The backprop to input in the forward pass. Has the same shape
      as input.
  input_h_backprop: The backprop to input_h in the forward pass. Has the same
      shape as input_h.
  input_c_backprop: The backprop to input_c in the forward pass. Has the same
      shape as input_c.
  params_backprop: The backprop to the params buffer in the forward pass. Has the
      same shape as params.

  Args:
    input: A `Tensor`. Must be one of the following types: `bfloat16`, `half`, `float32`, `float64`.
    input_h: A `Tensor`. Must have the same type as `input`.
    input_c: A `Tensor`. Must have the same type as `input`.
    params: A `Tensor`. Must have the same type as `input`.
    output: A `Tensor`. Must have the same type as `input`.
    output_h: A `Tensor`. Must have the same type as `input`.
    output_c: A `Tensor`. Must have the same type as `input`.
    output_backprop: A `Tensor`. Must have the same type as `input`.
    output_h_backprop: A `Tensor`. Must have the same type as `input`.
    output_c_backprop: A `Tensor`. Must have the same type as `input`.
    reserve_space: A `Tensor`. Must have the same type as `input`.
    host_reserved: A `Tensor` of type `int8`.
    rnn_mode: An optional `string` from: `"rnn_relu", "rnn_tanh", "lstm", "gru"`. Defaults to `"lstm"`.
    input_mode: An optional `string` from: `"linear_input", "skip_input", "auto_select"`. Defaults to `"linear_input"`.
    direction: An optional `string` from: `"unidirectional", "bidirectional"`. Defaults to `"unidirectional"`.
    dropout: An optional `float`. Defaults to `0`.
    seed: An optional `int`. Defaults to `0`.
    seed2: An optional `int`. Defaults to `0`.
    name: A name for the operation (optional).

  Returns:
    A tuple of `Tensor` objects (input_backprop, input_h_backprop, input_c_backprop, params_backprop).

    input_backprop: A `Tensor`. Has the same type as `input`.
    input_h_backprop: A `Tensor`. Has the same type as `input`.
    input_c_backprop: A `Tensor`. Has the same type as `input`.
    params_backprop: A `Tensor`. Has the same type as `input`.
  rr   r   r   r   r    r!   r"   Nrm   r(   r)   r*   r   r   r   r   r   r   r   r   ri   rj   rk   r   rt   r&   r,   )rr   )r-   r   r.   r/   r   r0   _CudnnRNNBackpropV2Outputr2   r3   r4   r5   r6   r7   $cudnn_rnn_backprop_v2_eager_fallbackr9   r:   r;   r<   r=   r?   r@   rA   rB   rC   rD   rF   rG   )r   r   r   r   r   r   r   ri   rj   rk   r   rt   r   r   r   r    r!   r"   r&   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   s                               rR   cudnn_rnn_backprop_v2rx   {  sp   V 
			0h..0$#\\11"D%'6(O5F=-Xj+y)Wgu&g *//8gn Hx4(J  \:* I	;7)_G3'	\D			4	($
]E


E7
+%'88)$))3:)DK)%+)4:)EM) (0) />	)
 1B) 1B) -:) -:) EM) *4) @I) '.) 59) AF) $()!QX QK'""$3%%c*Jll:&ll<(+ll;'CLL4Kc''/(*F ::LlFG=%++G4'	.q && -
##At,,## 
1
'668X
,.?
9g5t7 7 ## 
s1    AI JI//JJJ+ +KKzraw_ops.CudnnRNNBackpropV2c                 X   |d}t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d	      }|d}t        j                  |d
      }t        j                  | |||||||||	|
g|t
        j                  t
        j                  t
        j                  t
        j                  g      \  }}|\  } }}}}}}}}}	}
t        j                  |t
        j                        }| |||||||||	|
|g}d|d|d|d|d|d	|d
|f}t        j                  dd||||      }t        j                         rt        j                  d|||       t         j#                  |      }|S )Nr(   r   r)   r   r*   r   r   r    r!   r"   r,   s   CudnnRNNBackpropV2rV   rW   rr   )r:   r;   r<   r=   rY   rZ   r[   r\   r]   r^   r5   convert_to_tensorint8r   rA   rG   rv   r2   )r   r   r   r   r   r   r   ri   rj   rk   r   rt   r   r   r   r    r!   r"   r&   r'   r`   ra   rQ   rP   rK   s                            rR   rw   rw     sF   Hx4(J  \:* I	;7)_G3'	\D			4	($
]E


E7
+%66wQWY_aiks  vE  GX  Zk  mz  8{  }@  CJ  CS  CS  U\  Ua  Ua  cj  cr  cr  t{  tC  tC  BF  G'9 IR  F5'7FFHhQbdu  xE((E-'668X`q  tE  GT  Vc  d,*hjy)WfdGUL&2Al#)s?'""$lFG=%++G4'	.rb   CudnnRNNBackpropV3TV_CudnnRNNBackpropV3_Tsequence_lengthsnum_proj
time_majorc                    t         j                   xs t        j                         }|j                  }|j                  rk	 t	        j
                  g |d|| |||||||||	|
||d|d|d|d|d|d|d|d	| }t        j                  |      }|S |d}t        j                   |d      }|d}t        j                   |d      }|d}t        j                   |d      }|d}t        j"                  |d      }|d}t        j$                  |d      }|d}t        j$                  |d      }|d}t        j$                  |d      }|d}t        j&                  |d	      }t)        j*                  	 d i d| d|d|d|d|d|d|d|d|d|	d|
d|d|d|d|d|d|d|d|d|d	|d|\  }}}}|d
d
 }t        j,                         rd|j/                  d      d|j1                  d      d|j1                  d      d|j1                  d      d|j1                  d      d|j3                  d      d|j3                  d      d|j3                  d      d	|j5                  d	      f}|j6                  }t        j8                  d|||       t        j                  |      }|S # t        j                  $ r }t        j                  ||       Y d
}~nd
}~wt        j                  $ r Y nw xY w	 t        | |||||||||	|
||f||||||||||d
S # t        j                  $ r Y w xY w)!au  Backprop step of CudnnRNNV3.

  Compute the backprop of both data and weights in a RNN. Takes an extra
      "sequence_lengths" input than CudnnRNNBackprop.

  rnn_mode: Indicates the type of the RNN model.
  input_mode: Indicates whether there is a linear projection between the input and
      the actual computation before the first layer. 'skip_input' is only allowed
      when input_size == num_units; 'auto_select' implies 'skip_input' when
      input_size == num_units; otherwise, it implies 'linear_input'.
  direction: Indicates whether a bidirectional model will be used. Should be
    "unidirectional" or "bidirectional".
  dropout: Dropout probability. When set to 0., dropout is disabled.
  seed: The 1st part of a seed to initialize dropout.
  seed2: The 2nd part of a seed to initialize dropout.
  input: If time_major is true, this is a 3-D tensor with the shape of
      [seq_length, batch_size, input_size]. If time_major is false, the shape is
      [batch_size, seq_length, input_size].
  input_h: If time_major is true, this is a 3-D tensor with the shape of
      [num_layer * dir, batch_size, num_units]. If time_major is false, the shape
      is [batch_size, num_layer * dir, num_units].
  input_c: For LSTM, a 3-D tensor with the shape of
      [num_layer * dir, batch, num_units]. For other models, it is ignored.
  params: A 1-D tensor that contains the weights and biases in an opaque layout.
      The size must be created through CudnnRNNParamsSize, and initialized
      separately. Note that they might not be compatible across different
      generations. So it is a good idea to save and restore
  sequence_lengths: a vector of lengths of each input sequence.
  output: If time_major is true, this is a 3-D tensor with the shape of
      [seq_length, batch_size, dir * num_units]. If time_major is false, the
      shape is [batch_size, seq_length, dir * num_units].
  output_h: The same shape has input_h.
  output_c: The same shape as input_c for LSTM. An empty tensor for other models.
  output_backprop: A 3-D tensor with the same shape as output in the forward pass.
  output_h_backprop: A 3-D tensor with the same shape as output_h in the forward
      pass.
  output_c_backprop: A 3-D tensor with the same shape as output_c in the forward
      pass.
  time_major: Indicates whether the input/output format is time major or batch
      major.
  reserve_space: The same reserve_space produced in the forward operation.
  input_backprop: The backprop to input in the forward pass. Has the same shape
      as input.
  input_h_backprop: The backprop to input_h in the forward pass. Has the same
      shape as input_h.
  input_c_backprop: The backprop to input_c in the forward pass. Has the same
      shape as input_c.
  params_backprop: The backprop to the params buffer in the forward pass. Has the
      same shape as params.

  Args:
    input: A `Tensor`. Must be one of the following types: `bfloat16`, `half`, `float32`, `float64`.
    input_h: A `Tensor`. Must have the same type as `input`.
    input_c: A `Tensor`. Must have the same type as `input`.
    params: A `Tensor`. Must have the same type as `input`.
    sequence_lengths: A `Tensor` of type `int32`.
    output: A `Tensor`. Must have the same type as `input`.
    output_h: A `Tensor`. Must have the same type as `input`.
    output_c: A `Tensor`. Must have the same type as `input`.
    output_backprop: A `Tensor`. Must have the same type as `input`.
    output_h_backprop: A `Tensor`. Must have the same type as `input`.
    output_c_backprop: A `Tensor`. Must have the same type as `input`.
    reserve_space: A `Tensor`. Must have the same type as `input`.
    host_reserved: A `Tensor` of type `int8`.
    rnn_mode: An optional `string` from: `"rnn_relu", "rnn_tanh", "lstm", "gru"`. Defaults to `"lstm"`.
    input_mode: An optional `string` from: `"linear_input", "skip_input", "auto_select"`. Defaults to `"linear_input"`.
    direction: An optional `string` from: `"unidirectional", "bidirectional"`. Defaults to `"unidirectional"`.
    dropout: An optional `float`. Defaults to `0`.
    seed: An optional `int`. Defaults to `0`.
    seed2: An optional `int`. Defaults to `0`.
    num_proj: An optional `int`. Defaults to `0`.
    time_major: An optional `bool`. Defaults to `True`.
    name: A name for the operation (optional).

  Returns:
    A tuple of `Tensor` objects (input_backprop, input_h_backprop, input_c_backprop, params_backprop).

    input_backprop: A `Tensor`. Has the same type as `input`.
    input_h_backprop: A `Tensor`. Has the same type as `input`.
    input_c_backprop: A `Tensor`. Has the same type as `input`.
    params_backprop: A `Tensor`. Has the same type as `input`.
  r|   r   r   r   r    r!   r"   r   r   N)
r   r   r   r    r!   r"   r   r   r&   r'   r(   r)   r*   r   Tr   r   r   r   r~   r   r   r   ri   rj   rk   r   rt   r&   r,   )r|   )r-   r   r.   r/   r   r0   _CudnnRNNBackpropV3Outputr2   r3   r4   r5   r6   r7   $cudnn_rnn_backprop_v3_eager_fallbackr9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   )r   r   r   r   r~   r   r   r   ri   rj   rk   r   rt   r   r   r   r    r!   r"   r   r   r&   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   s                                  rR   cudnn_rnn_backprop_v3r   7  s   f 
			0h..0$#\\11 88"8$(8*/8188:A8CI88 8"*8,486E8 	8 -8 /<8 >K8 		8 	8 +	8 -7	8 9D	8
 	8
 8
 &8
 (.8
 048
 6=8
 ?D8 	8 8 +8 -78g *//8gn  Hx4(J  \:* I	;7)_G3'	\D			4	($
]E


E7
+%Hx4(J!!*l;*'88)$))3:)DK)%+) 0@) &,	) 7?	)
 (0) />) 1B) 1B) -:) -:) EM) *4) @I) '.) 59) AF) (0) =G) $()!QX QK'""$3%%c*Jll:&ll<(+ll;'CLL4Kc''/(*
+\  .0F ::LlFG=%++G4'	.I && -
##At,,## 
	1
'6+;VX
O%68I
 2:9g58
  ## 
s1    A)K LK22L
L L0 0MMzraw_ops.CudnnRNNBackpropV3c                    |d}t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d	      }|d}t        j                  |d
      }|d}t        j                  |d      }|d}t        j                  |d      }t        j
                  | ||||||||	|
|g|t        j                  t        j                  t        j                  t        j                  g      \  }}|\  } }}}}}}}}	}
}t        j                  |t        j                        }t        j                  |t        j                        }| |||||||||	|
||g}d|d|d|d|d|d	|d
|d|d|f}t        j                  dd||||      }t        j                          rt        j"                  d|||       t$        j'                  |      }|S )Nr(   r   r)   r   r*   r   r   r    r!   r"   r   Tr   r,   s   CudnnRNNBackpropV3rV   rW   r|   )r:   r;   r<   r=   r>   rY   rZ   r[   r\   r]   r^   r5   rz   int32r{   r   rA   rG   r   r2   )r   r   r   r   r~   r   r   r   ri   rj   rk   r   rt   r   r   r   r    r!   r"   r   r   r&   r'   r`   ra   rQ   rP   rK   s                               rR   r   r     s   Hx4(J  \:* I	;7)_G3'	\D			4	($
]E


E7
+%Hx4(J!!*l;*66wQWY_aiks  vE  GX  Zk  mz  8{  }@  CJ  CS  CS  U\  Ua  Ua  cj  cr  cr  t{  tC  tC  BF  G'9 IR  F5'7FFHhQbdu  xE++,<gmmL((E-'63CVXW_ap  sD  FW  Yf  hu  v,*hjy)WfdGUhj2& 2Al#)s?'""$lFG=%++G4'	.rb   TV_CudnnRNNCanonicalToParams_T
num_layers	num_units
input_sizeweightsbiasesreturnc                    t         j                   xs t        j                         }|j                  }|j                  r+	 t	        j
                  |d|| ||||d|d|d|d|d|	d|
      }|S t        |t        t        f      st!        d
|z        t#        |      }t        |t        t        f      st!        d|z        t#        |      |k7  rt%        dt#        |      |fz        |d}t'        j(                  |d      }|d}t'        j(                  |d      }|d}t'        j(                  |d      }|d}t'        j*                  |d      }|	d}	t'        j,                  |	d      }	|
d}
t'        j,                  |
d      }
t/        j0                  d| |||||||||	|
|      \  }}}}|dd }t'        j2                         rd|j5                  d      d|j7                  d      d|j9                  d      d|j9                  d      d|j9                  d      d|j9                  d      d|j7                  d      d|j7                  d      f}|j:                  }t'        j<                  d|||       |\  }|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)aF
  Converts CudnnRNN params from canonical form to usable form.

  Writes a set of weights into the opaque params buffer so they can be used in
  upcoming training or inferences.

  Note that the params buffer may not be compatible across different GPUs. So any
  save and restoration should be converted to and from the canonical weights and
  biases.

  num_layers: Specifies the number of layers in the RNN model.
  num_units: Specifies the size of the hidden state.
  input_size: Specifies the size of the input state.
  weights: the canonical form of weights that can be used for saving
      and restoration. They are more likely to be compatible across different
      generations.
  biases: the canonical form of biases that can be used for saving
      and restoration. They are more likely to be compatible across different
      generations.
  num_params: number of parameter sets for all layers.
      Each layer may contain multiple parameter sets, with each set consisting of
      a weight matrix and a bias vector.
  rnn_mode: Indicates the type of the RNN model.
  input_mode: Indicate whether there is a linear projection between the input and
      The actual computation before the first layer. 'skip_input' is only allowed
      when input_size == num_units; 'auto_select' implies 'skip_input' when
      input_size == num_units; otherwise, it implies 'linear_input'.
  direction: Indicates whether a bidirectional model will be used.
      dir = (direction == bidirectional) ? 2 : 1
  dropout: dropout probability. When set to 0., dropout is disabled.
  seed: the 1st part of a seed to initialize dropout.
  seed2: the 2nd part of a seed to initialize dropout.

  Args:
    num_layers: A `Tensor` of type `int32`.
    num_units: A `Tensor` of type `int32`.
    input_size: A `Tensor` of type `int32`.
    weights: A list of at least 1 `Tensor` objects with the same type in: `bfloat16`, `half`, `float32`, `float64`.
    biases: A list with the same length as `weights` of `Tensor` objects with the same type as `weights`.
    rnn_mode: An optional `string` from: `"rnn_relu", "rnn_tanh", "lstm", "gru"`. Defaults to `"lstm"`.
    input_mode: An optional `string` from: `"linear_input", "skip_input", "auto_select"`. Defaults to `"linear_input"`.
    direction: An optional `string` from: `"unidirectional", "bidirectional"`. Defaults to `"unidirectional"`.
    dropout: An optional `float`. Defaults to `0`.
    seed: An optional `int`. Defaults to `0`.
    seed2: An optional `int`. Defaults to `0`.
    name: A name for the operation (optional).

  Returns:
    A `Tensor`. Has the same type as `weights`.
  CudnnRNNCanonicalToParamsr   r   r   r    r!   r"   Nrm   SExpected list for 'weights' argument to 'cudnn_rnn_canonical_to_params' Op, not %r.RExpected list for 'biases' argument to 'cudnn_rnn_canonical_to_params' Op, not %r.wList argument 'biases' to 'cudnn_rnn_canonical_to_params' Op with length %d must match length %d of argument 'weights'.r(   r)   r*   r   )r   r   r   r   r   r   r   r   r    r!   r"   r&   r,   
num_params)r-   r   r.   r/   r   r0   r3   r4   r5   r6   r7   ,cudnn_rnn_canonical_to_params_eager_fallbackr9   
isinstancelisttuple	TypeErrorlen
ValueErrorr:   r;   r<   r=   r?   r@   rA   rB   rD   rC   rF   rG   )r   r   r   r   r   r   r   r   r    r!   r"   r&   rI   rJ   rK   rL   _attr_num_paramsrM   rN   rO   rP   rQ   s                         rR   cudnn_rnn_canonical_to_paramsr     sC   d 
			0h..0$#\\
11)4YGVZ<KIw	g
 n 
GdE]	+
	68?	@A A \	FT5M	*
	68>	?@ @ 	[$$
	6	V&'	() ) Hx4(J  \:* I	;7)_G3'	\D			4	($
]E


E7
+%'88#
/80:G,2X0:/8'*.e$H!QX QK'""$3%%c*L-zll:&ll<(+ll;'CLL4Kc''/(*F ::L#\67D('	.C && -
##At,,## 
9
iWf
iE$H H ## 
s0    )I4 4J;J""J;:J;?K K.-K.z!raw_ops.CudnnRNNCanonicalToParamsc                    t        |t        t        f      st        d|z        t	        |      }t        |t        t        f      st        d|z        t	        |      |k7  rt        dt	        |      |fz        |d}t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d	      }|d
}t        j                  |d      }|	d
}	t        j                  |	d      }	|
d
}
t        j                  |
d      }
t        j                  t        |      t        |      z   |t        j                  t        j                  t        j                  t        j                  g      \  }}|d | g||d  z   }|d d |dd  gz   }|\  }}t!        j"                  | t        j$                        } t!        j"                  |t        j$                        }t!        j"                  |t        j$                        }| ||gt        |      z   t        |      z   }d|d|d|d|d	|d|d|	d|
f}t        j&                  dd||||      }t        j(                         rt        j*                  d|||       |\  }|S )Nr   r   r   r(   r   r)   r   r*   r   r   r    r!   r"      r,   r   s   CudnnRNNCanonicalToParamsrW   r   )r   r   r   r   r   r   r:   r;   r<   r=   rY   rZ   r[   r\   r]   r^   r5   rz   r   r   rA   rG   )r   r   r   r   r   r   r   r   r    r!   r"   r&   r'   r   r`   ra   rQ   rP   rK   s                      rR   r   r     s   	GdE]	+
	68?	@A A \	FT5M	*
	68>	?@ @ 	[$$
	6	V&'	() ) Hx4(J  \:* I	;7)_G3'	\D			4	($
]E


E7
+%66tG}tF|7SUX[b[k[kmtmymy  |C  |K  |K  MT  M\  M\  [_  `'9**+,y9I9J/KK)my}o-)7F%%j'--@*$$Y>)%%j'--@*i4tG}DtF|S,,(8*
L*k9i	64%)& 91$0C"&(' ""$#\67D('	.rb    TV_CudnnRNNCanonicalToParamsV2_Tc                 *   t         j                   xs t        j                         }|j                  }|j                  r-	 t	        j
                  |d|| ||||d|d|d|d|d|	d|
d|      }|S t        |t        t        f      st!        d|z        t#        |      }t        |t        t        f      st!        d|z        t#        |      }|d}t%        j&                  |d      }|d}t%        j&                  |d      }|d}t%        j&                  |d      }|d}t%        j(                  |d      }|	d}	t%        j*                  |	d      }	|
d}
t%        j*                  |
d      }
|d}t%        j*                  |d      }t-        j.                  d| |||||||||	|
||      \  }}}}|d	d	 }t%        j0                         rd|j3                  d      d|j5                  d      d|j5                  d      d|j7                  d      d|j7                  d      d|j7                  d      d|j7                  d      d|j5                  d      d|j5                  d      d|j5                  d      f}|j8                  }t%        j:                  d|||       |\  }|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
  Converts CudnnRNN params from canonical form to usable form. It supports the projection in LSTM.

  Writes a set of weights into the opaque params buffer so they can be used in
  upcoming training or inferences.

  Note that the params buffer may not be compatible across different GPUs. So any
  save and restoration should be converted to and from the canonical weights and
  biases.

  num_layers: Specifies the number of layers in the RNN model.
  num_units: Specifies the size of the hidden state.
  input_size: Specifies the size of the input state.
  weights: the canonical form of weights that can be used for saving
      and restoration. They are more likely to be compatible across different
      generations.
  biases: the canonical form of biases that can be used for saving
      and restoration. They are more likely to be compatible across different
      generations.
  num_params_weights: number of weight parameter matrix for all layers.
  num_params_biases: number of bias parameter vector for all layers.
  rnn_mode: Indicates the type of the RNN model.
  input_mode: Indicate whether there is a linear projection between the input and
      The actual computation before the first layer. 'skip_input' is only allowed
      when input_size == num_units; 'auto_select' implies 'skip_input' when
      input_size == num_units; otherwise, it implies 'linear_input'.
  direction: Indicates whether a bidirectional model will be used.
      dir = (direction == bidirectional) ? 2 : 1
  dropout: dropout probability. When set to 0., dropout is disabled.
  seed: the 1st part of a seed to initialize dropout.
  seed2: the 2nd part of a seed to initialize dropout.
  num_proj: The output dimensionality for the projection matrices. If None or 0,
      no projection is performed.

  Args:
    num_layers: A `Tensor` of type `int32`.
    num_units: A `Tensor` of type `int32`.
    input_size: A `Tensor` of type `int32`.
    weights: A list of at least 1 `Tensor` objects with the same type in: `bfloat16`, `half`, `float32`, `float64`.
    biases: A list of at least 1 `Tensor` objects with the same type as `weights`.
    rnn_mode: An optional `string` from: `"rnn_relu", "rnn_tanh", "lstm", "gru"`. Defaults to `"lstm"`.
    input_mode: An optional `string` from: `"linear_input", "skip_input", "auto_select"`. Defaults to `"linear_input"`.
    direction: An optional `string` from: `"unidirectional", "bidirectional"`. Defaults to `"unidirectional"`.
    dropout: An optional `float`. Defaults to `0`.
    seed: An optional `int`. Defaults to `0`.
    seed2: An optional `int`. Defaults to `0`.
    num_proj: An optional `int`. Defaults to `0`.
    name: A name for the operation (optional).

  Returns:
    A `Tensor`. Has the same type as `weights`.
  CudnnRNNCanonicalToParamsV2r   r   r   r    r!   r"   r   N)	r   r   r   r    r!   r"   r   r&   r'   VExpected list for 'weights' argument to 'cudnn_rnn_canonical_to_params_v2' Op, not %r.UExpected list for 'biases' argument to 'cudnn_rnn_canonical_to_params_v2' Op, not %r.r(   r)   r*   r   )r   r   r   r   r   r   r   r   r    r!   r"   r   r&   r,   num_params_weightsnum_params_biases)r-   r   r.   r/   r   r0   r3   r4   r5   r6   r7   /cudnn_rnn_canonical_to_params_v2_eager_fallbackr9   r   r   r   r   r   r:   r;   r<   r=   r?   r@   rA   rB   rD   rC   rF   rG   )r   r   r   r   r   r   r   r   r    r!   r"   r   r&   rI   rJ   rK   rL   _attr_num_params_weights_attr_num_params_biasesrM   rN   rO   rP   rQ   s                           rR    cudnn_rnn_canonical_to_params_v2r     sd   h 
			0h..0$#\\
11+T:yGVZ<KIw
H	.g
 n 
GdE]	+
	9;B	CD D !\	FT5M	*
	9;A	BC C  KHx4(J  \:* I	;7)_G3'	\D			4	($
]E


E7
+%Hx4('88%*1:2<g.4x2<1:G,008tE!QX QK'""$3%%c*,@ 457J 34jll:&ll<(+ll;'CLL4Kc''/(*
+-F ::L%|VWF('	.I && -
##At,,## 
<
iWf
iEH	 
 ## 
s0    +J K*KKK"K; ;LLz#raw_ops.CudnnRNNCanonicalToParamsV2c                    t        |t        t        f      st        d|z        t	        |      }t        |t        t        f      st        d|z        t	        |      }|d}t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d      }|d	}t        j                  |d
      }|	d	}	t        j                  |	d      }	|
d	}
t        j                  |
d      }
|d	}t        j                  |d      }t        j                  t        |      t        |      z   |t        j                  t        j                  t        j                  t        j                  g      \  }}|d | g||d  z   }|d d |dd  gz   }|\  }}t        j                   | t        j"                        } t        j                   |t        j"                        }t        j                   |t        j"                        }| ||gt        |      z   t        |      z   }d|d|d|d|d|d|d
|d|	d|
d|f}t        j$                  dd||||      }t        j&                         rt        j(                  d|||       |\  }|S )Nr   r   r(   r   r)   r   r*   r   r   r    r!   r"   r   r   r,   r   r   s   CudnnRNNCanonicalToParamsV2rW   r   )r   r   r   r   r   r:   r;   r<   r=   rY   rZ   r[   r\   r]   r^   r5   rz   r   r   rA   rG   )r   r   r   r   r   r   r   r   r    r!   r"   r   r&   r'   r   r   r`   ra   rQ   rP   rK   s                        rR   r   r   M  s   	GdE]	+
	9;B	CD D !\	FT5M	*
	9;A	BC C  KHx4(J  \:* I	;7)_G3'	\D			4	($
]E


E7
+%Hx4(66tG}tF|7SUX[b[k[kmtmymy  |C  |K  |K  MT  M\  M\  [_  `'92234yAYAZ7[[)my}o-)7F%%j'--@*$$Y>)%%j'--@*i4tG}DtF|S,.0H.
H
KIw$
H6& ;Q$0C"&(' ""$%|VWF('	.rb   TV_CudnnRNNParamsSize_TTV_CudnnRNNParamsSize_Sz_atypes.Int32z_atypes.Int64r,   Sc                    t         j                   xs t        j                         }|j                  }|j                  r/	 t	        j
                  |d|| ||d|d|d|d|d|d|d|	d	|
d
|      }|S t        j                  |d      }t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d      }|d}t        j                   |d      }|	d}	t        j"                  |	d      }	|
d}
t        j"                  |
d	      }
|d}t        j"                  |d
      }t%        j&                  d| |||||||||	|
||      \  }}}}|dd }t        j(                         rd|j+                  d      d|j+                  d      d|j-                  d      d|j-                  d      d|j-                  d      d|j-                  d      d|j/                  d      d	|j/                  d	      d
|j/                  d
      f}|j0                  }t        j2                  d|||       |\  }|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 bw xY w)a  Computes size of weights that can be used by a Cudnn RNN model.

  Return the params size that can be used by the Cudnn RNN model. Subsequent
  weight allocation and initialization should use this size.

  num_layers: Specifies the number of layers in the RNN model.
  num_units: Specifies the size of the hidden state.
  input_size: Specifies the size of the input state.
  rnn_mode: Indicates the type of the RNN model.
  input_mode: Indicate whether there is a linear projection between the input and
    The actual computation before the first layer. 'skip_input' is only allowed
    when input_size == num_units; 'auto_select' implies 'skip_input' when
    input_size == num_units; otherwise, it implies 'linear_input'.
  direction: Indicates whether a bidirectional model will be used.
    dir = (direction == bidirectional) ? 2 : 1
  dropout: dropout probability. When set to 0., dropout is disabled.
  seed: the 1st part of a seed to initialize dropout.
  seed2: the 2nd part of a seed to initialize dropout.
  params_size: The size of the params buffer that should be allocated and
    initialized for this RNN model. Note that this params buffer may not be
    compatible across GPUs. Please use CudnnRNNParamsWeights and
    CudnnRNNParamsBiases to save and restore them in a way that is compatible
    across different runs.

  Args:
    num_layers: A `Tensor` of type `int32`.
    num_units: A `Tensor` of type `int32`.
    input_size: A `Tensor` of type `int32`.
    T: A `tf.DType` from: `tf.bfloat16, tf.half, tf.float32, tf.float64`.
    S: A `tf.DType` from: `tf.int32, tf.int64`.
    rnn_mode: An optional `string` from: `"rnn_relu", "rnn_tanh", "lstm", "gru"`. Defaults to `"lstm"`.
    input_mode: An optional `string` from: `"linear_input", "skip_input", "auto_select"`. Defaults to `"linear_input"`.
    direction: An optional `string` from: `"unidirectional", "bidirectional"`. Defaults to `"unidirectional"`.
    dropout: An optional `float`. Defaults to `0`.
    seed: An optional `int`. Defaults to `0`.
    seed2: An optional `int`. Defaults to `0`.
    num_proj: An optional `int`. Defaults to `0`.
    name: A name for the operation (optional).

  Returns:
    A `Tensor` of type `S`.
  CudnnRNNParamsSizer,   r   r   r   r   r    r!   r"   r   N)r,   r   r   r   r   r    r!   r"   r   r&   r'   r(   r)   r*   r   )r   r   r   r,   r   r   r   r   r    r!   r"   r   r&   )r-   r   r.   r/   r   r0   r3   r4   r5   r6   r7   $cudnn_rnn_params_size_eager_fallbackr9   r:   	make_typer;   r<   r=   r?   r@   rA   rB   rC   rD   rF   rG   )r   r   r   r,   r   r   r   r   r    r!   r"   r   r&   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   s                         rR   cudnn_rnn_params_sizer     s   V 
			0h..0$#\\
11"D*iQQ
HlJY	7FD'z8	%g
 n C !C !Hx4(J  \:* I	;7)_G3'	\D			4	($
]E


E7
+%Hx4('88y)3qA'/J(17$)H4I!QX QK'""$3%%c*C1C1CC1H#,,z2Lll<(+ll;'CLL4Kc''/(*
+-F ::LlFG=('	.m && -
##At,,## 
1
iqA9g58$DJ J ## 
s0    -I J)JJJ!J: :KKzraw_ops.CudnnRNNParamsSizec                 j   t        j                  |d      }t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d      }|d	}t        j                  |d
      }|	d	}	t        j                  |	d      }	|
d	}
t        j                  |
d      }
|d	}t        j                  |d      }t        j                  | t        j                        } t        j                  |t        j                        }t        j                  |t        j                        }| ||g}d|d|d|d|d|d
|d|	d|
d|f}t        j                  dd||||      }t        j                         rt        j                  d|||       |\  }|S )Nr,   r   r(   r   r)   r   r*   r   r   r    r!   r"   r   s   CudnnRNNParamsSizer   rW   r   )r:   r   r;   r<   r=   r5   rz   rZ   r   r   rA   rG   )r   r   r   r,   r   r   r   r   r    r!   r"   r   r&   r'   rQ   rP   rK   s                    rR   r   r     s   C !C !Hx4(J  \:* I	;7)_G3'	\D			4	($
]E


E7
+%Hx4(%%j'--@*$$Y>)%%j'--@*i4,CJ,
y)WfdGUh& 2Al#)s?'""$lFG=('	.rb   CudnnRNNParamsToCanonicalTV_CudnnRNNParamsToCanonical_Tr   c                    t         j                   xs t        j                         }|j                  }|j                  rA	 t	        j
                  |d|| |||d|d|d|d|d|d|	d|
      }t        j                  |      }|S t        j                   |d      }|d}t        j"                  |d      }|d}t        j"                  |d      }|d}t        j"                  |d      }|d}t        j$                  |d      }|	d}	t        j                   |	d      }	|
d}
t        j                   |
d      }
t'        j(                  d| |||||||||	|
|      \  }}}}|d	d	 }t        j*                         rd|j-                  d      d|j/                  d      d|j1                  d      d|j1                  d      d|j1                  d      d|j1                  d      d|j/                  d      d|j/                  d      f}|j2                  }t        j4                  d|||       |d	| g||d	 z   }|d	d |dd	 g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 Hw xY w)a
  Retrieves CudnnRNN params in canonical form.

  Retrieves a set of weights from the opaque params buffer that can be saved and
  restored in a way compatible with future runs.

  Note that the params buffer may not be compatible across different GPUs. So any
  save and restoration should be converted to and from the canonical weights and
  biases.

  num_layers: Specifies the number of layers in the RNN model.
  num_units: Specifies the size of the hidden state.
  input_size: Specifies the size of the input state.
  num_params: number of parameter sets for all layers.
      Each layer may contain multiple parameter sets, with each set consisting of
      a weight matrix and a bias vector.
  weights: the canonical form of weights that can be used for saving
      and restoration. They are more likely to be compatible across different
      generations.
  biases: the canonical form of biases that can be used for saving
      and restoration. They are more likely to be compatible across different
      generations.
  rnn_mode: Indicates the type of the RNN model.
  input_mode: Indicate whether there is a linear projection between the input and
      The actual computation before the first layer. 'skip_input' is only allowed
      when input_size == num_units; 'auto_select' implies 'skip_input' when
      input_size == num_units; otherwise, it implies 'linear_input'.
  direction: Indicates whether a bidirectional model will be used.
      dir = (direction == bidirectional) ? 2 : 1
  dropout: dropout probability. When set to 0., dropout is disabled.
  seed: the 1st part of a seed to initialize dropout.
  seed2: the 2nd part of a seed to initialize dropout.

  Args:
    num_layers: A `Tensor` of type `int32`.
    num_units: A `Tensor` of type `int32`.
    input_size: A `Tensor` of type `int32`.
    params: A `Tensor`. Must be one of the following types: `bfloat16`, `half`, `float32`, `float64`.
    num_params: An `int` that is `>= 1`.
    rnn_mode: An optional `string` from: `"rnn_relu", "rnn_tanh", "lstm", "gru"`. Defaults to `"lstm"`.
    input_mode: An optional `string` from: `"linear_input", "skip_input", "auto_select"`. Defaults to `"linear_input"`.
    direction: An optional `string` from: `"unidirectional", "bidirectional"`. Defaults to `"unidirectional"`.
    dropout: An optional `float`. Defaults to `0`.
    seed: An optional `int`. Defaults to `0`.
    seed2: An optional `int`. Defaults to `0`.
    name: A name for the operation (optional).

  Returns:
    A tuple of `Tensor` objects (weights, biases).

    weights: A list of `num_params` `Tensor` objects with the same type as `params`.
    biases: A list of `num_params` `Tensor` objects with the same type as `params`.
  r   r   r   r   r   r    r!   r"   N)	r   r   r   r   r    r!   r"   r&   r'   r(   r)   r*   r   )r   r   r   r   r   r   r   r   r    r!   r"   r&   r,   r   )r-   r   r.   r/   r   r0    _CudnnRNNParamsToCanonicalOutputr2   r3   r4   r5   r6   r7   ,cudnn_rnn_params_to_canonical_eager_fallbackr9   r:   r=   r;   r<   r?   r@   rA   rB   rD   rC   rF   rG   )r   r   r   r   r   r   r   r   r    r!   r"   r&   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   s                        rR   cudnn_rnn_params_to_canonicalr   $  s   j 
			0h..0$#\\11)4YFL*j(j+y)Wgu	&g
 166w?gn   \:*Hx4(J  \:* I	;7)_G3'	\D			4	($
]E


E7
+%'88#
/80:60:X0:/8'*.e$H!QX QK'""$3%%c*L-zll:&ll<(+ll;'CLL4Kc''/(*F ::L#\67D[j!"WZ[%99'BQK712;-'',227;'	.m && -
##At,,## 
9
iV

iE$H H ## 
s0    ?I J"I==JJJ2 2K	K	z!raw_ops.CudnnRNNParamsToCanonicalc                    t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d	      }|	d}	t        j                  |	d
      }	|
d}
t        j                  |
d      }
t        j                  |g|t
        j                  t
        j                  t
        j                  t
        j                  g      \  }\  }t        j                  | t
        j                        } t        j                  |t
        j                        }t        j                  |t
        j                        }| |||g}d|d|d|d|d|d	|d
|	d|
f}t        j                  d||z   ||||      }t        j                         rt        j                  d|||       |d | g||d  z   }|d d |dd  gz   }t         j#                  |      }|S )Nr   r(   r   r)   r   r*   r   r   r    r!   r"   r,   s   CudnnRNNParamsToCanonicalrW   r   r   )r:   r=   r;   r<   rY   rZ   r[   r\   r]   r^   r5   rz   r   r   rA   rG   r   r2   )r   r   r   r   r   r   r   r   r    r!   r"   r&   r'   r`   rQ   rP   rK   s                    rR   r   r     s      \:*Hx4(J  \:* I	;7)_G3'	\D			4	($
]E


E7
+%66xwGWGWY`YeYegngvgvx  yH  yH  GK  L'9F%%j'--@*$$Y>)%%j'--@*iV<,,
J
KIw$ & 9:'<(0<F!$41' ""$#\67D[j!"WZ[%99'BQK712;-'',227;'	.rb   CudnnRNNParamsToCanonicalV2 TV_CudnnRNNParamsToCanonicalV2_Tr   r   c                 L   t         j                   xs t        j                         }|j                  }|j                  rE	 t	        j
                  |d|| |||d|d|d|d|d|d|	d|
d	|d
|      }t        j                  |      }|S t        j                   |d      }t        j                   |d      }|d}t        j"                  |d      }|d}t        j"                  |d      }|d}t        j"                  |d      }|	d}	t        j$                  |	d      }	|
d}
t        j                   |
d      }
|d}t        j                   |d	      }|d}t        j                   |d
      }t'        j(                  d| |||||||||	|
|||      \  }}}}|dd }t        j*                         rd|j-                  d      d|j/                  d      d|j/                  d      d|j1                  d      d|j1                  d      d|j1                  d      d|j1                  d      d|j/                  d      d	|j/                  d	      d
|j/                  d
      f}|j2                  }t        j4                  d|||       |d| g||d z   }|dd |dd g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  Retrieves CudnnRNN params in canonical form. It supports the projection in LSTM.

  Retrieves a set of weights from the opaque params buffer that can be saved and
  restored in a way compatible with future runs.

  Note that the params buffer may not be compatible across different GPUs. So any
  save and restoration should be converted to and from the canonical weights and
  biases.

  num_layers: Specifies the number of layers in the RNN model.
  num_units: Specifies the size of the hidden state.
  input_size: Specifies the size of the input state.
  num_params_weights: number of weight parameter matrix for all layers.
  num_params_biases: number of bias parameter vector for all layers.
  weights: the canonical form of weights that can be used for saving
      and restoration. They are more likely to be compatible across different
      generations.
  biases: the canonical form of biases that can be used for saving
      and restoration. They are more likely to be compatible across different
      generations.
  rnn_mode: Indicates the type of the RNN model.
  input_mode: Indicate whether there is a linear projection between the input and
      The actual computation before the first layer. 'skip_input' is only allowed
      when input_size == num_units; 'auto_select' implies 'skip_input' when
      input_size == num_units; otherwise, it implies 'linear_input'.
  direction: Indicates whether a bidirectional model will be used.
      dir = (direction == bidirectional) ? 2 : 1
  dropout: dropout probability. When set to 0., dropout is disabled.
  seed: the 1st part of a seed to initialize dropout.
  seed2: the 2nd part of a seed to initialize dropout.
  num_proj: The output dimensionality for the projection matrices. If None or 0,
      no projection is performed.

  Args:
    num_layers: A `Tensor` of type `int32`.
    num_units: A `Tensor` of type `int32`.
    input_size: A `Tensor` of type `int32`.
    params: A `Tensor`. Must be one of the following types: `bfloat16`, `half`, `float32`, `float64`.
    num_params_weights: An `int` that is `>= 1`.
    num_params_biases: An `int` that is `>= 1`.
    rnn_mode: An optional `string` from: `"rnn_relu", "rnn_tanh", "lstm", "gru"`. Defaults to `"lstm"`.
    input_mode: An optional `string` from: `"linear_input", "skip_input", "auto_select"`. Defaults to `"linear_input"`.
    direction: An optional `string` from: `"unidirectional", "bidirectional"`. Defaults to `"unidirectional"`.
    dropout: An optional `float`. Defaults to `0`.
    seed: An optional `int`. Defaults to `0`.
    seed2: An optional `int`. Defaults to `0`.
    num_proj: An optional `int`. Defaults to `0`.
    name: A name for the operation (optional).

  Returns:
    A tuple of `Tensor` objects (weights, biases).

    weights: A list of `num_params_weights` `Tensor` objects with the same type as `params`.
    biases: A list of `num_params_biases` `Tensor` objects with the same type as `params`.
  r   r   r   r   r   r   r    r!   r"   r   N)r   r   r   r   r   r    r!   r"   r   r&   r'   r(   r)   r*   r   )r   r   r   r   r   r   r   r   r   r    r!   r"   r   r&   r,   r   )r-   r   r.   r/   r   r0   "_CudnnRNNParamsToCanonicalV2Outputr2   r3   r4   r5   r6   r7   /cudnn_rnn_params_to_canonical_v2_eager_fallbackr9   r:   r=   r;   r<   r?   r@   rA   rB   rD   rC   rF   rG   )r   r   r   r   r   r   r   r   r   r    r!   r"   r   r&   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   s                          rR    cudnn_rnn_params_to_canonical_v2r     s   p 
			0h..0$#\\11+T:yF02D.
Hj+y)Wguj(<g 388Agn  (();=QR''(9;NOHx4(J  \:* I	;7)_G3'	\D			4	($
]E


E7
+%Hx4('88%*1:2<V:L9J082<1:G,008t
E!QX QK'""$3%%c*,@ 457J 34jll:&ll<(+ll;'CLL4Kc''/(*
+-F ::L%|VWF(()*W5G5H-II'BQK712;-''.44W='	.C && -
##At,,## 
<
iV/-9g58$DJ J ## 
s1    AJ' 'K.:KK.-K.2L L#"L#z#raw_ops.CudnnRNNParamsToCanonicalV2c                 z   t        j                  |d      }t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d      }|	d	}	t        j                  |	d
      }	|
d	}
t        j                  |
d      }
|d	}t        j                  |d      }|d	}t        j                  |d      }t        j                  |g|t
        j                  t
        j                  t
        j                  t
        j                  g      \  }\  }t        j                  | t
        j                        } t        j                  |t
        j                        }t        j                  |t
        j                        }| |||g}d|d|d|d|d|d|d
|	d|
d|d|f}t        j                  d||z   ||||      }t        j                         rt        j                  d|||       |d | g||d  z   }|d d |dd  gz   }t         j#                  |      }|S )Nr   r   r(   r   r)   r   r*   r   r   r    r!   r"   r   r,   s   CudnnRNNParamsToCanonicalV2rW   r   r   )r:   r=   r;   r<   rY   rZ   r[   r\   r]   r^   r5   rz   r   r   rA   rG   r   r2   )r   r   r   r   r   r   r   r   r   r    r!   r"   r   r&   r'   r`   rQ   rP   rK   s                      rR   r   r   W  sd   (();=QR''(9;NOHx4(J  \:* I	;7)_G3'	\D			4	($
]E


E7
+%Hx4(66xwGWGWY`YeYegngvgvx  yH  yH  GK  L'9F%%j'--@*$$Y>)%%j'--@*iV<,.0B(*hk9i&$	5*h(& ;/2CC$0C"&(' ""$%|VWF(()*W5G5H-II'BQK712;-''.44W='	.rb   
CudnnRNNV2)r   r   r   r   rt   TV_CudnnRNNV2_Tc                 p   t         j                   xs t        j                         }|j                  }|j                  rA	 t	        j
                  |d|| |||d|d|d|d|d|d|	d|
      }t        j                  |      }|S |d}t        j                   |d      }|d}t        j                   |d      }|d}t        j                   |d      }|d}t        j"                  |d      }|d}t        j$                  |d      }|	d}	t        j$                  |	d      }	|
d}
t        j&                  |
d      }
t)        j*                  d| |||||||||	|
|      \  }}}}|d	d	 }t        j,                         rd|j/                  d      d|j1                  d      d|j1                  d      d|j1                  d      d|j1                  d      d|j3                  d      d|j3                  d      d|j5                  d      f}|j6                  }t        j8                  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 4w xY w)a  A RNN backed by cuDNN.

  Computes the RNN from the input and initial states, with respect to the params
  buffer. Produces one extra output "host_reserved" than CudnnRNN.

  rnn_mode: Indicates the type of the RNN model.
  input_mode: Indicates whether there is a linear projection between the input and
    the actual computation before the first layer. 'skip_input' is only allowed
    when input_size == num_units; 'auto_select' implies 'skip_input' when
    input_size == num_units; otherwise, it implies 'linear_input'.
  direction: Indicates whether a bidirectional model will be used. Should be
    "unidirectional" or "bidirectional".
  dropout: Dropout probability. When set to 0., dropout is disabled.
  seed: The 1st part of a seed to initialize dropout.
  seed2: The 2nd part of a seed to initialize dropout.
  input: A 3-D tensor with the shape of [seq_length, batch_size, input_size].
  input_h: A 3-D tensor with the shape of [num_layer * dir, batch_size,
      num_units].
  input_c: For LSTM, a 3-D tensor with the shape of
      [num_layer * dir, batch, num_units]. For other models, it is ignored.
  params: A 1-D tensor that contains the weights and biases in an opaque layout.
      The size must be created through CudnnRNNParamsSize, and initialized
      separately. Note that they might not be compatible across different
      generations. So it is a good idea to save and restore
  output: A 3-D tensor with the shape of [seq_length, batch_size,
      dir * num_units].
  output_h: The same shape has input_h.
  output_c: The same shape as input_c for LSTM. An empty tensor for other models.
  is_training: Indicates whether this operation is used for inference or
    training.
  reserve_space: An opaque tensor that can be used in backprop calculation. It
    is only produced if is_training is true.
  host_reserved: An opaque tensor that can be used in backprop calculation. It is
    only produced if is_training is true. It is output on host memory rather than
    device memory.

  Args:
    input: A `Tensor`. Must be one of the following types: `bfloat16`, `half`, `float32`, `float64`.
    input_h: A `Tensor`. Must have the same type as `input`.
    input_c: A `Tensor`. Must have the same type as `input`.
    params: A `Tensor`. Must have the same type as `input`.
    rnn_mode: An optional `string` from: `"rnn_relu", "rnn_tanh", "lstm", "gru"`. Defaults to `"lstm"`.
    input_mode: An optional `string` from: `"linear_input", "skip_input", "auto_select"`. Defaults to `"linear_input"`.
    direction: An optional `string` from: `"unidirectional", "bidirectional"`. Defaults to `"unidirectional"`.
    dropout: An optional `float`. Defaults to `0`.
    seed: An optional `int`. Defaults to `0`.
    seed2: An optional `int`. Defaults to `0`.
    is_training: An optional `bool`. Defaults to `True`.
    name: A name for the operation (optional).

  Returns:
    A tuple of `Tensor` objects (output, output_h, output_c, reserve_space, host_reserved).

    output: A `Tensor`. Has the same type as `input`.
    output_h: A `Tensor`. Has the same type as `input`.
    output_c: A `Tensor`. Has the same type as `input`.
    reserve_space: A `Tensor`. Has the same type as `input`.
    host_reserved: A `Tensor` of type `int8`.
  r   r   r   r   r    r!   r"   r#   Nr%   r(   r)   r*   r   Tr+   r,   )r-   r   r.   r/   r   r0   _CudnnRNNV2Outputr2   r3   r4   r5   r6   r7   cudnn_rnnv2_eager_fallbackr9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   s                        rR   cudnn_rnnv2r     s   x 
			0h..0$#\\
11lD%'6:,
KIw}kKg "''0gn Hx4(J  \:* I	;7)_G3'	\D			4	($
]E


E7
+%K"";>+'88E7G#h: )7!{	G!QX
 QK'""$3%%c*Jll:&ll<(+ll;'CLL4Kc''/(-  /1F ::LlFG5##G,'	.i && -
##At,,## 
'
'6H9g5k	 
 ## 
rT   zraw_ops.CudnnRNNV2c                    |d}t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d	      }|	d}	t        j                  |	d
      }	|
d}
t        j                  |
d      }
t        j
                  | |||g|t        j                  t        j                  t        j                  t        j                  g      \  }}|\  } }}}| |||g}d|d|d|d|d|d	|d
|	d|
f}t        j                  dd||||      }t        j                         rt        j                  d|||       t        j                  |      }|S )Nr(   r   r)   r   r*   r   r   r    r!   r"   Tr#   r,   s
   CudnnRNNV2   rW   r   )r:   r;   r<   r=   r>   rY   rZ   r[   r\   r]   r^   r   rA   rG   r   r2   r_   s                     rR   r   r   
  s   Hx4(J  \:* I	;7)_G3'	\D			4	($
]E


E7
+%K"";>+66wQW7XZ]`g`p`pryr~r~  AH  AP  AP  RY  Ra  Ra  `d  e'9&/#5'7F'62,*hjy)WfdGU& ]Al#)s?'""$lFG5##G,'	.rb   
CudnnRNNV3TV_CudnnRNNV3_Tc                 0   t         j                   xs t        j                         }|j                  }|j                  rF	 t	        j
                  |d|| ||||d|d|d|d|d|	d|
d|d	|d
|      }t        j                  |      }|S |d}t        j                   |d      }|d}t        j                   |d      }|d}t        j                   |d      }|d}t        j"                  |d      }|	d}	t        j$                  |	d      }	|
d}
t        j$                  |
d      }
|d}t        j$                  |d      }|d}t        j&                  |d	      }|d}t        j&                  |d
      }t)        j*                  	 d| |||||||||	|
||||d\  }}}}|dd }t        j,                         rd|j/                  d      d|j1                  d      d|j1                  d      d|j1                  d      d|j1                  d      d|j3                  d      d|j3                  d      d|j3                  d      d	|j5                  d	      d
|j5                  d
      f}|j6                  }t        j8                  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  A RNN backed by cuDNN.

  Computes the RNN from the input and initial states, with respect to the params
  buffer. Accepts one extra input "sequence_lengths" than CudnnRNN.

  rnn_mode: Indicates the type of the RNN model.
  input_mode: Indicates whether there is a linear projection between the input and
    the actual computation before the first layer. 'skip_input' is only allowed
    when input_size == num_units; 'auto_select' implies 'skip_input' when
    input_size == num_units; otherwise, it implies 'linear_input'.
  direction: Indicates whether a bidirectional model will be used. Should be
    "unidirectional" or "bidirectional".
  dropout: Dropout probability. When set to 0., dropout is disabled.
  seed: The 1st part of a seed to initialize dropout.
  seed2: The 2nd part of a seed to initialize dropout.
  input: If time_major is true, this is a 3-D tensor with the shape of
      [seq_length, batch_size, input_size]. If time_major is false, the shape is
      [batch_size, seq_length, input_size].
  input_h: If time_major is true, this is a 3-D tensor with the shape of
      [num_layer * dir, batch_size, num_units]. If time_major is false, the shape
      is [batch_size, num_layer * dir, num_units].
  input_c: For LSTM, a 3-D tensor with the shape of
      [num_layer * dir, batch, num_units]. For other models, it is ignored.
  params: A 1-D tensor that contains the weights and biases in an opaque layout.
      The size must be created through CudnnRNNParamsSize, and initialized
      separately. Note that they might not be compatible across different
      generations. So it is a good idea to save and restore
  sequence_lengths: a vector of lengths of each input sequence.
  output: If time_major is true, this is a 3-D tensor with the shape of
      [seq_length, batch_size, dir * num_units]. If time_major is false, the
      shape is [batch_size, seq_length, dir * num_units].
  output_h: The same shape has input_h.
  output_c: The same shape as input_c for LSTM. An empty tensor for other models.
  is_training: Indicates whether this operation is used for inference or
    training.
  time_major: Indicates whether the input/output format is time major or batch
      major.
  reserve_space: An opaque tensor that can be used in backprop calculation. It
    is only produced if is_training is true.

  Args:
    input: A `Tensor`. Must be one of the following types: `bfloat16`, `half`, `float32`, `float64`.
    input_h: A `Tensor`. Must have the same type as `input`.
    input_c: A `Tensor`. Must have the same type as `input`.
    params: A `Tensor`. Must have the same type as `input`.
    sequence_lengths: A `Tensor` of type `int32`.
    rnn_mode: An optional `string` from: `"rnn_relu", "rnn_tanh", "lstm", "gru"`. Defaults to `"lstm"`.
    input_mode: An optional `string` from: `"linear_input", "skip_input", "auto_select"`. Defaults to `"linear_input"`.
    direction: An optional `string` from: `"unidirectional", "bidirectional"`. Defaults to `"unidirectional"`.
    dropout: An optional `float`. Defaults to `0`.
    seed: An optional `int`. Defaults to `0`.
    seed2: An optional `int`. Defaults to `0`.
    num_proj: An optional `int`. Defaults to `0`.
    is_training: An optional `bool`. Defaults to `True`.
    time_major: An optional `bool`. Defaults to `True`.
    name: A name for the operation (optional).

  Returns:
    A tuple of `Tensor` objects (output, output_h, output_c, reserve_space, host_reserved).

    output: A `Tensor`. Has the same type as `input`.
    output_h: A `Tensor`. Has the same type as `input`.
    output_c: A `Tensor`. Has the same type as `input`.
    reserve_space: A `Tensor`. Has the same type as `input`.
    host_reserved: A `Tensor` of type `int8`.
  r   r   r   r   r    r!   r"   r   r#   r   N)r   r   r   r    r!   r"   r   r#   r   r&   r'   r(   r)   r*   r   T)r   r   r   r   r~   r   r   r   r    r!   r"   r   r#   r   r&   r,   )r   )r-   r   r.   r/   r   r0   _CudnnRNNV3Outputr2   r3   r4   r5   r6   r7   cudnn_rnnv3_eager_fallbackr9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   )r   r   r   r   r~   r   r   r   r    r!   r"   r   r#   r   r&   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   s                           rR   cudnn_rnnv3r   5  s[   F 
			0h..0$#\\11lD%'6*hjY	7FD'z8]Kg "''0gn Hx4(J  \:* I	;7)_G3'	\D			4	($
]E


E7
+%Hx4(K"";>+J!!*l;*'888!7G#6F'J )7!H+!+$8!QX QK'""$3%%c*Jll:&ll<(+ll;'CLL4Kc''/(*
+]  /  .0F ::LlFG5##G,'	.} && -
##At,,## 
'
'6+;
iEH!jt	O O
 ## 
s1    AJ K+KKK#K> >LLzraw_ops.CudnnRNNV3c                    |d}t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d      }|	d}	t        j                  |	d	      }	|
d}
t        j                  |
d
      }
|d}t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d      }t        j
                  | |||g|t        j                  t        j                  t        j                  t        j                  g      \  }}|\  } }}}t        j                  |t        j                        }| ||||g}d|d|d|d|d|d	|	d
|
d|d|d|f}t        j                  dd||||      }t        j                         rt        j                   d|||       t"        j%                  |      }|S )Nr(   r   r)   r   r*   r   r   r    r!   r"   r   Tr#   r   r,   s
   CudnnRNNV3r   rW   r   )r:   r;   r<   r=   r>   rY   rZ   r[   r\   r]   r^   r5   rz   r   r   rA   rG   r   r2   )r   r   r   r   r~   r   r   r   r    r!   r"   r   r#   r   r&   r'   r`   ra   rQ   rP   rK   s                        rR   r   r     s-   Hx4(J  \:* I	;7)_G3'	\D			4	($
]E


E7
+%Hx4(K"";>+J!!*l;*66wQW7XZ]`g`p`pryr~r~  AH  AP  AP  RY  Ra  Ra  `d  e'9&/#5'7F++,<gmmL'63CD,*hjy)WfdGUh{L*N& ]Al#)s?'""$lFG5##G,'	.rb   )r(   r)   r*   r   r   r   TN)r(   r)   r*   r   r   r   N)	r(   r)   r*   r   r   r   r   TN)r(   r)   r*   r   r   r   r   N)
r(   r)   r*   r   r   r   r   TTN)a__doc__collectionstensorflow.pythonr   tensorflow.python.eagerr   r-   r   r3   r   r:   tensorflow.python.frameworkr   rZ   tensorflow.security.fuzzing.pyr   _atypesr	   _op_def_registryr
   r5   r   r?   "tensorflow.python.util.deprecationr   tensorflow.python.utilr   	_dispatch tensorflow.python.util.tf_exportr   typingr   r   r   typing_extensionsr   
namedtupler1   r   strfloatintboolrS   	to_raw_opr   r8   rn   rh   rp   rc   ro   rv   rs   Int8rx   rr   rw   r   r}   Int32r   r|   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    rb   rR   <module>r      s!  
  6 7 1 7 9 F K 3 I C 8 6 % % '(+((79
 );=NPacqrvYsM12 vYsMGY=Z venor  uB  pB  fC v  MV  WZ  \i  Wi  Mj v  ux v  LO v  jm v  HM v  VY v  cf v  vz vp )9'(	)BC"Ic=.@$A "IVY[hVhLi "t}  B  DQ  Q  uR "  \e  fi  kx  fx  \y "  EH "  VY "  fi "  ty "  AD "  MP "  _c "H 1+00QS 
   79KM^`q  tB  C Ji-B(BC JiX[]rXrNs J  H  IL  Nc  Ic  d J  nw  x{  }R  xR  nS J  ]f  gj  lA  gA  ]B J  NW  X[  ]r  Xr  Ns J  H  IL  Nc  Ic  d J  w@  AD  F[  A[  w\ J  qz  {~  @U  {U  qV J  kt  ux  zO  uO  kP J  aj  kn  pE	  kE	  aF	 J  Q	T	 J  h	k	 J  F
I
 J  d
i
 J  r
u
 J  
B JX 9978HZ9[\ Ys<Q7Q-R ]fgj  mB  hB  ^C   NW  X[  ]r  Xr  Ns   }F  GJ  La  Ga  }b   lu  vy  {P  vP  lQ   ]f  gj  lA  gA  ]B   NW  X[  ]r  Xr  Ns   FO  PS  Uj  Pj  Fk   @I  JM  Od  Jd  @e   zC  DG  I^  D^  z_   py  z}  T	  zT	  pU	   a	d	   r	u	   B
E
   P
U
   ]
`
   i
l
 @ 3K22QS 
 "";=OQbdu  xF  G O30G+G!H OS\]`by]ySz O  FO  PS  Ul  Pl  Fm O  w@  AD  F]  A]  w^ O  hq  ru  wN  rN  hO O  [d  eh  jA  eA  [B O  NW  X[  ]t  Xt  Nu O  HQ  RU  Wn  Rn  Ho O  DM  NQ  Sj  Nj  Dk O  @I  JM  Of  Jf  @g O  xA	  B	E	  G	^	  B	^	  x_	 O  p	y	  z	}	  	F
  	K
  	K
  z	K
  p	L
 O  W
Z
 O  n
q
 O  LO O  jo O  x{ O  EH Ob =Y;<^T^^La=bc 	#?V:V0W bklo  rI  mI  cJ   U^  _b  d{  _{  U|   FO  PS  Ul  Pl  Fm   w@  AD  F]  A]  w^   js  tw  yP  tP  jQ   ]f  gj  lC  gC  ]D   W`  ad  f}  a}  W~   S\  ]`  by  ]y  Sz   OX  Y\  ^u  Yu  Ov   G	P	  Q	T	  V	m	  Q	m	  G	n	   	H
  I
L
  N
U
  N
Z
  N
Z
  I
Z
  	[
   g
j
   x
{
   HK   V[   cf   or B 3K22QS 
 "";=OQbdu  xF  G d30G+G!H dS\]`by]ySz d  FO  PS  Ul  Pl  Fm d  w@  AD  F]  A]  w^ d  r{  |  AH  AN  AN  |N  rO d  Yb  cf  h  c  Y@ d  LU  VY  [r  Vr  Ls d  H  IL  Ne  Ie  f d  yB  CF  H_  C_  y` d  u~  B  D[  [  u\ d  qz  {~  @	W	  {W	  qX	 d  i	r	  s	v	  x	O
  s	O
  i	P
 d  a
j
  k
n
  p
w
  p
|
  p
|
  k
|
  a
}
 d  HK d  _b d  }@ d  [` d  il d  vy d  FI d  X\ dL =Y;<^T^^La=bc '	#?V:V0W 'bklo  rI  mI  cJ '  U^  _b  d{  _{  U| '  FO  PS  Ul  Pl  Fm '  AJ  KN  PW  P]  P]  K]  A^ '  hq  ru  wN  rN  hO '  [d  eh  jA  eA  [B '  NW  X[  ]t  Xt  Nu '  HQ  RU  Wn  Rn  Ho '  DM  NQ  Sj  Nj  Dk '  @	I	  J	M	  O	f	  J	f	  @	g	 '  x	A
  B
E
  G
^
  B
^
  x	_
 '  p
y
  z
}
  
F  
K  
K  z
K  p
L '  X[ '  il '  y| '  GL '  TW '  `c '  or '  @D 'T "))IK]_p  sD  FT  "U }iW]]8J.K }XabegngtgtbtXu }  DM  NQ  SZ  S`  S`  N`  Da }  lu  vz  {~  v  A_  v_  l` }  js  tx  y|  t}  ]  t]  j^ }  il }  @C }  ^a }  |A }  JM }  WZ }  lu  vy  {Y  vY  lZ }~ KI&IJ>4>>ZwKxy 3YsGMMGY=Z 3gpqtv}  wD  wD  rD  hE 3  S\  ]`  bi  bo  bo  ]o  Sp 3  {D  EI  JM  EN  Pn  En  {o 3  yB  CG  HK  CL  Nl  Cl  ym 3  y| 3  JM 3  Z] 3  hm 3  ux 3  AD 3  T]  ^a  cA  ^A  TB 3l $++MOact  wH  JX  $Y  B3;M1N B[dehjqjwjwew[x B  GP  QT  V]  Vc  Vc  Qc  Gd B  ox  y}  ~A  yB  Dd  yd  oe B  ox  y}  ~A  yB  Dd  yd  oe B  ps B  GJ B  eh B  CH B  QT B  ^a B  nq B  CL  MP  Rr  Mr  Cs BH Oi(MN~t~~^~O  A 3	#w}}J\@] 3jstw  zA  zG  zG  uG  kH 3  V_  `c  el  er  er  `r  Vs 3  ~G  HL  MP  HQ  Ss  Hs  ~t 3  ~G  HL  MP  HQ  Ss  Hs  ~t 3  @C 3  QT 3  ad 3  ot 3  | 3  HK 3  WZ 3  js  tw  yY  tY  jZ 3l "";=OQbdu  xF  G !";_o^ kiW]]0B&C kPYZ]_f_l_lZlPm k  |E  FI  KR  KX  KX  FX  |Y k  ^u k  zQ k  \_ k  sv k  QT k  ot k  }@ k  JM k  Z] k  ox  y|  ~U  yU  oV kZ =Y;<^T^^La=bc %YsGMM?Q5R %_hilnun{n{i{_| %  KT  UX  Za  Zg  Zg  Ug  Kh %  mD %  I` %  lo %  }@ %  MP %  [` %  hk %  tw %  CF %  V_  `c  e|  `|  V} %N $:;#9#9$  
 "))IK]_p  sD  FT  "U viW]]8J.K vXabegngtgtbtXu v  DM  NQ  SZ  S`  S`  N`  Da v  kt  ux  zX  uX  kY v  gj v  ux v  LO v  jm v  HM v  VY v  cf vp KI&IJ>4>>ZwKxy %YsGMMGY=Z %gpqtv}  wD  wD  rD  hE %  S\  ]`  bi  bo  bo  ]o  Sp %  zC  DG  Ig  Dg  zh %  vy %  EH %  VY %  fi %  ty %  AD %  MP %N &<[%;%;!& "
 $++MOact  wH  JX  $Y  E3;M1N E[dehjqjwjwew[x E  GP  QT  V]  Vc  Vc  Qc  Gd E  nw  x{  }]  x]  n^ E  tw E  LO E  Z] E  qt E  OR E  mr E  {~ E  HK E  X[ EN Oi(MN~t~~^~O  A +	#w}}J\@] +jstw  zA  zG  zG  uG  kH +  V_  `c  el  er  er  `r  Vs +  }F  GJ  Ll  Gl  }m +  CF +  [^ +  jm +  {~ +  KN +  Y^ +  fi +  ru +  AD +Z +K**HJ 
 +-?ARTeguvzyo!56 z3P_K_A` zktux  {J  vJ  lK z  U^  _b  ds  _s  Ut z  B z  VY z  tw z  RW z  `c z  mp z  @D zx -Y+,^T^^K-HI
"i_0D&E "PYZ]_nZnPo "  {D  EH  JY  EY  {Z "  dm  nq  sB  nB  dC "  OR "  `c "  ps "  ~C "  KN "  WZ "  im "H +K**HJ 
 +-?ARTeguvMyo!56 M3P_K_A` Mktux  {J  vJ  lK M  U^  _b  ds  _s  Ut M  HQ  RU  W^  Wd  Wd  Rd  He M  ps M  GJ M  eh M  CH M  QT M  ^a M  nq M  AE M  W[ M^ -Y+,^T^^K-HI
)i_0D&E )PYZ]_nZnPo )  {D  EH  JY  EY  {Z )  dm  nq  sB  nB  dC )  W`  ad  fm  fs  fs  as  Wt )  @C )  QT )  ad )  ot )  | )  HK )  WZ )  im )  { )rb   