@tf_export('block_lstm_grad')
def block_lstm_grad(seq_len_max, x, cs_prev, h_prev, w, wci, wcf, wco, b, i, cs, f, o, ci, co, h, cs_grad, h_grad, use_peephole, name=None):
    'Computes the LSTM cell backward propagation for the entire time sequence.\n\n  This implementation is to be used in conjunction of LSTMBlock.\n\n  Args:\n    seq_len_max: A `Tensor` of type `int64`.\n      Maximum time length actually used by this input. Outputs are padded\n      with zeros beyond this length.\n    x: A `Tensor`. Must be one of the following types: `half`, `float32`.\n      The sequence input to the LSTM, shape (timelen, batch_size, num_inputs).\n    cs_prev: A `Tensor`. Must have the same type as `x`.\n      Value of the initial cell state.\n    h_prev: A `Tensor`. Must have the same type as `x`.\n      Initial output of cell (to be used for peephole).\n    w: A `Tensor`. Must have the same type as `x`. The weight matrix.\n    wci: A `Tensor`. Must have the same type as `x`.\n      The weight matrix for input gate peephole connection.\n    wcf: A `Tensor`. Must have the same type as `x`.\n      The weight matrix for forget gate peephole connection.\n    wco: A `Tensor`. Must have the same type as `x`.\n      The weight matrix for output gate peephole connection.\n    b: A `Tensor`. Must have the same type as `x`. The bias vector.\n    i: A `Tensor`. Must have the same type as `x`.\n      The input gate over the whole time sequence.\n    cs: A `Tensor`. Must have the same type as `x`.\n      The cell state before the tanh over the whole time sequence.\n    f: A `Tensor`. Must have the same type as `x`.\n      The forget gate over the whole time sequence.\n    o: A `Tensor`. Must have the same type as `x`.\n      The output gate over the whole time sequence.\n    ci: A `Tensor`. Must have the same type as `x`.\n      The cell input over the whole time sequence.\n    co: A `Tensor`. Must have the same type as `x`.\n      The cell after the tanh over the whole time sequence.\n    h: A `Tensor`. Must have the same type as `x`.\n      The output h vector over the whole time sequence.\n    cs_grad: A `Tensor`. Must have the same type as `x`.\n      The current gradient of cs.\n    h_grad: A `Tensor`. Must have the same type as `x`.\n      The gradient of h vector.\n    use_peephole: A `bool`. Whether to use peephole weights.\n    name: A name for the operation (optional).\n\n  Returns:\n    A tuple of `Tensor` objects (x_grad, cs_prev_grad, h_prev_grad, w_grad, wci_grad, wcf_grad, wco_grad, b_grad).\n\n    x_grad: A `Tensor`. Has the same type as `x`. The gradient of x to be back-propped.\n    cs_prev_grad: A `Tensor`. Has the same type as `x`. The gradient of cs_prev to be back-propped.\n    h_prev_grad: A `Tensor`. Has the same type as `x`. The gradient of h_prev to be back-propped.\n    w_grad: A `Tensor`. Has the same type as `x`. The gradient for w to be back-propped.\n    wci_grad: A `Tensor`. Has the same type as `x`. The gradient for wci to be back-propped.\n    wcf_grad: A `Tensor`. Has the same type as `x`. The gradient for wcf to be back-propped.\n    wco_grad: A `Tensor`. Has the same type as `x`. The gradient for wco to be back-propped.\n    b_grad: A `Tensor`. Has the same type as `x`. The gradient for w to be back-propped.\n  '
    _ctx = _context._context
    if ((_ctx is None) or (not _ctx._eager_context.is_eager)):
        use_peephole = _execute.make_bool(use_peephole, 'use_peephole')
        (_, _, _op) = _op_def_lib._apply_op_helper('BlockLSTMGrad', seq_len_max=seq_len_max, x=x, cs_prev=cs_prev, h_prev=h_prev, w=w, wci=wci, wcf=wcf, wco=wco, b=b, i=i, cs=cs, f=f, o=o, ci=ci, co=co, h=h, cs_grad=cs_grad, h_grad=h_grad, use_peephole=use_peephole, name=name)
        _result = _op.outputs[:]
        _inputs_flat = _op.inputs
        _attrs = ('use_peephole', _op.get_attr('use_peephole'), 'T', _op.get_attr('T'))
        _execute.record_gradient('BlockLSTMGrad', _inputs_flat, _attrs, _result, name)
        _result = _BlockLSTMGradOutput._make(_result)
        return _result
    else:
        try:
            _result = _pywrap_tensorflow.TFE_Py_FastPathExecute(_ctx._context_handle, _ctx._eager_context.device_name, 'BlockLSTMGrad', name, _ctx._post_execution_callbacks, seq_len_max, x, cs_prev, h_prev, w, wci, wcf, wco, b, i, cs, f, o, ci, co, h, cs_grad, h_grad, 'use_peephole', use_peephole)
            _result = _BlockLSTMGradOutput._make(_result)
            return _result
        except _core._FallbackException:
            return block_lstm_grad_eager_fallback(seq_len_max, x, cs_prev, h_prev, w, wci, wcf, wco, b, i, cs, f, o, ci, co, h, cs_grad, h_grad, use_peephole=use_peephole, name=name, ctx=_ctx)
        except _core._NotOkStatusException as e:
            if (name is not None):
                message = ((e.message + ' name: ') + name)
            else:
                message = e.message
            _six.raise_from(_core._status_to_exception(e.code, message), None)
Computes the LSTM cell backward propagation for the entire time sequence.

This implementation is to be used in conjunction of LSTMBlock.

Args:
  seq_len_max: A `Tensor` of type `int64`.
    Maximum time length actually used by this input. Outputs are padded
    with zeros beyond this length.
  x: A `Tensor`. Must be one of the following types: `half`, `float32`.
    The sequence input to the LSTM, shape (timelen, batch_size, num_inputs).
  cs_prev: A `Tensor`. Must have the same type as `x`.
    Value of the initial cell state.
  h_prev: A `Tensor`. Must have the same type as `x`.
    Initial output of cell (to be used for peephole).
  w: A `Tensor`. Must have the same type as `x`. The weight matrix.
  wci: A `Tensor`. Must have the same type as `x`.
    The weight matrix for input gate peephole connection.
  wcf: A `Tensor`. Must have the same type as `x`.
    The weight matrix for forget gate peephole connection.
  wco: A `Tensor`. Must have the same type as `x`.
    The weight matrix for output gate peephole connection.
  b: A `Tensor`. Must have the same type as `x`. The bias vector.
  i: A `Tensor`. Must have the same type as `x`.
    The input gate over the whole time sequence.
  cs: A `Tensor`. Must have the same type as `x`.
    The cell state before the tanh over the whole time sequence.
  f: A `Tensor`. Must have the same type as `x`.
    The forget gate over the whole time sequence.
  o: A `Tensor`. Must have the same type as `x`.
    The output gate over the whole time sequence.
  ci: A `Tensor`. Must have the same type as `x`.
    The cell input over the whole time sequence.
  co: A `Tensor`. Must have the same type as `x`.
    The cell after the tanh over the whole time sequence.
  h: A `Tensor`. Must have the same type as `x`.
    The output h vector over the whole time sequence.
  cs_grad: A `Tensor`. Must have the same type as `x`.
    The current gradient of cs.
  h_grad: A `Tensor`. Must have the same type as `x`.
    The gradient of h vector.
  use_peephole: A `bool`. Whether to use peephole weights.
  name: A name for the operation (optional).

Returns:
  A tuple of `Tensor` objects (x_grad, cs_prev_grad, h_prev_grad, w_grad, wci_grad, wcf_grad, wco_grad, b_grad).

  x_grad: A `Tensor`. Has the same type as `x`. The gradient of x to be back-propped.
  cs_prev_grad: A `Tensor`. Has the same type as `x`. The gradient of cs_prev to be back-propped.
  h_prev_grad: A `Tensor`. Has the same type as `x`. The gradient of h_prev to be back-propped.
  w_grad: A `Tensor`. Has the same type as `x`. The gradient for w to be back-propped.
  wci_grad: A `Tensor`. Has the same type as `x`. The gradient for wci to be back-propped.
  wcf_grad: A `Tensor`. Has the same type as `x`. The gradient for wcf to be back-propped.
  wco_grad: A `Tensor`. Has the same type as `x`. The gradient for wco to be back-propped.
  b_grad: A `Tensor`. Has the same type as `x`. The gradient for w to be back-propped.
@tf_export('block_lstm_grad')
def block_lstm_grad(seq_len_max, x, cs_prev, h_prev, w, wci, wcf, wco, b, i, cs, f, o, ci, co, h, cs_grad, h_grad, use_peephole, name=None):
    'Computes the LSTM cell backward propagation for the entire time sequence.\n\n  This implementation is to be used in conjunction of LSTMBlock.\n\n  Args:\n    seq_len_max: A `Tensor` of type `int64`.\n      Maximum time length actually used by this input. Outputs are padded\n      with zeros beyond this length.\n    x: A `Tensor`. Must be one of the following types: `half`, `float32`.\n      The sequence input to the LSTM, shape (timelen, batch_size, num_inputs).\n    cs_prev: A `Tensor`. Must have the same type as `x`.\n      Value of the initial cell state.\n    h_prev: A `Tensor`. Must have the same type as `x`.\n      Initial output of cell (to be used for peephole).\n    w: A `Tensor`. Must have the same type as `x`. The weight matrix.\n    wci: A `Tensor`. Must have the same type as `x`.\n      The weight matrix for input gate peephole connection.\n    wcf: A `Tensor`. Must have the same type as `x`.\n      The weight matrix for forget gate peephole connection.\n    wco: A `Tensor`. Must have the same type as `x`.\n      The weight matrix for output gate peephole connection.\n    b: A `Tensor`. Must have the same type as `x`. The bias vector.\n    i: A `Tensor`. Must have the same type as `x`.\n      The input gate over the whole time sequence.\n    cs: A `Tensor`. Must have the same type as `x`.\n      The cell state before the tanh over the whole time sequence.\n    f: A `Tensor`. Must have the same type as `x`.\n      The forget gate over the whole time sequence.\n    o: A `Tensor`. Must have the same type as `x`.\n      The output gate over the whole time sequence.\n    ci: A `Tensor`. Must have the same type as `x`.\n      The cell input over the whole time sequence.\n    co: A `Tensor`. Must have the same type as `x`.\n      The cell after the tanh over the whole time sequence.\n    h: A `Tensor`. Must have the same type as `x`.\n      The output h vector over the whole time sequence.\n    cs_grad: A `Tensor`. Must have the same type as `x`.\n      The current gradient of cs.\n    h_grad: A `Tensor`. Must have the same type as `x`.\n      The gradient of h vector.\n    use_peephole: A `bool`. Whether to use peephole weights.\n    name: A name for the operation (optional).\n\n  Returns:\n    A tuple of `Tensor` objects (x_grad, cs_prev_grad, h_prev_grad, w_grad, wci_grad, wcf_grad, wco_grad, b_grad).\n\n    x_grad: A `Tensor`. Has the same type as `x`. The gradient of x to be back-propped.\n    cs_prev_grad: A `Tensor`. Has the same type as `x`. The gradient of cs_prev to be back-propped.\n    h_prev_grad: A `Tensor`. Has the same type as `x`. The gradient of h_prev to be back-propped.\n    w_grad: A `Tensor`. Has the same type as `x`. The gradient for w to be back-propped.\n    wci_grad: A `Tensor`. Has the same type as `x`. The gradient for wci to be back-propped.\n    wcf_grad: A `Tensor`. Has the same type as `x`. The gradient for wcf to be back-propped.\n    wco_grad: A `Tensor`. Has the same type as `x`. The gradient for wco to be back-propped.\n    b_grad: A `Tensor`. Has the same type as `x`. The gradient for w to be back-propped.\n  '
    _ctx = _context._context
    if ((_ctx is None) or (not _ctx._eager_context.is_eager)):
        use_peephole = _execute.make_bool(use_peephole, 'use_peephole')
        (_, _, _op) = _op_def_lib._apply_op_helper('BlockLSTMGrad', seq_len_max=seq_len_max, x=x, cs_prev=cs_prev, h_prev=h_prev, w=w, wci=wci, wcf=wcf, wco=wco, b=b, i=i, cs=cs, f=f, o=o, ci=ci, co=co, h=h, cs_grad=cs_grad, h_grad=h_grad, use_peephole=use_peephole, name=name)
        _result = _op.outputs[:]
        _inputs_flat = _op.inputs
        _attrs = ('use_peephole', _op.get_attr('use_peephole'), 'T', _op.get_attr('T'))
        _execute.record_gradient('BlockLSTMGrad', _inputs_flat, _attrs, _result, name)
        _result = _BlockLSTMGradOutput._make(_result)
        return _result
    else:
        try:
            _result = _pywrap_tensorflow.TFE_Py_FastPathExecute(_ctx._context_handle, _ctx._eager_context.device_name, 'BlockLSTMGrad', name, _ctx._post_execution_callbacks, seq_len_max, x, cs_prev, h_prev, w, wci, wcf, wco, b, i, cs, f, o, ci, co, h, cs_grad, h_grad, 'use_peephole', use_peephole)
            _result = _BlockLSTMGradOutput._make(_result)
            return _result
        except _core._FallbackException:
            return block_lstm_grad_eager_fallback(seq_len_max, x, cs_prev, h_prev, w, wci, wcf, wco, b, i, cs, f, o, ci, co, h, cs_grad, h_grad, use_peephole=use_peephole, name=name, ctx=_ctx)
        except _core._NotOkStatusException as e:
            if (name is not None):
                message = ((e.message + ' name: ') + name)
            else:
                message = e.message
            _six.raise_from(_core._status_to_exception(e.code, message), None)