parameters: (theta,
                state0,
                inputs,
                cell_fn,
                cell_grad=None,
                extras=None,
                max_input_length=None,
                use_tpu=False,
                aligned_end=False)
return_statement: return _Recurrent(
        cell_fn=cell_fn,
        cell_grad=cell_grad,
        theta=theta,
        state0=state0,
        inputs=inputs,
        max_input_length=max_input_length,
        extras=extras,
        use_tpu=use_tpu,
        aligned_end=aligned_end).Compute()
docstring: Compute a recurrent neural net.
  
    Roughly, Recurrent() computes the following:
      state = state0
      for t in inputs' sequence length:
        state = cell_fn(theta, state, inputs[t, :])
        accumulate_state[t, :] = state
      return accumulate_state, state
  
    theta, state, inputs are all structures of tensors.
  
    inputs[t, :] means taking a slice out from every tensor in the inputs.
  
    accumulate_state[t, :] = state means that we stash every tensor in
    'state' into a slice of the corresponding tensor in
    accumulate_state.
  
    cell_fn is a python callable computing (building up a TensorFlow
    graph) the recurrent neural network's one forward step. Two calls of
    cell_fn must describe two identical computations.
  
    By construction, Recurrent()'s backward computation does not access
    any intermediate values computed by cell_fn during forward
    computation. We may extend Recurrent() to support that by taking a
    customized backward function of cell_fn.
  
    Args:
      theta: weights. A structure of tensors.
      state0: initial state. A structure of tensors.
      inputs: inputs. A structure of tensors.
      cell_fn: A python function, which computes:
        state1, extras = cell_fn(theta, state0, inputs[t, :])
      cell_grad: A python function which computes:
        dtheta, dstate0, dinputs[t, :] = cell_grad(
          theta, state0, inputs[t, :], extras, dstate1)
      extras: A structure of tensors. The 2nd return value of every
        invocation of cell_fn is a structure of tensors with matching keys
        and shapes of  this `extras`.
      max_input_length: maximum length of effective input. This is used to
        truncate the computation if the inputs have been allocated to a
        larger size. A scalar tensor.
      use_tpu: whether or not we are on TPU.
      aligned_end: A boolean indicating whether the sequence is aligned at
        the end.
  
    Returns:
      accumulate_state and the final state.
docstring_summary: Compute a recurrent neural net.
docstring_tokens: Compute a recurrent neural net .
function: def Recurrent(theta,
                state0,
                inputs,
                cell_fn,
                cell_grad=None,
                extras=None,
                max_input_length=None,
                use_tpu=False,
                aligned_end=False):
    """Compute a recurrent neural net.
  
    Roughly, Recurrent() computes the following:
      state = state0
      for t in inputs' sequence length:
        state = cell_fn(theta, state, inputs[t, :])
        accumulate_state[t, :] = state
      return accumulate_state, state
  
    theta, state, inputs are all structures of tensors.
  
    inputs[t, :] means taking a slice out from every tensor in the inputs.
  
    accumulate_state[t, :] = state means that we stash every tensor in
    'state' into a slice of the corresponding tensor in
    accumulate_state.
  
    cell_fn is a python callable computing (building up a TensorFlow
    graph) the recurrent neural network's one forward step. Two calls of
    cell_fn must describe two identical computations.
  
    By construction, Recurrent()'s backward computation does not access
    any intermediate values computed by cell_fn during forward
    computation. We may extend Recurrent() to support that by taking a
    customized backward function of cell_fn.
  
    Args:
      theta: weights. A structure of tensors.
      state0: initial state. A structure of tensors.
      inputs: inputs. A structure of tensors.
      cell_fn: A python function, which computes:
        state1, extras = cell_fn(theta, state0, inputs[t, :])
      cell_grad: A python function which computes:
        dtheta, dstate0, dinputs[t, :] = cell_grad(
          theta, state0, inputs[t, :], extras, dstate1)
      extras: A structure of tensors. The 2nd return value of every
        invocation of cell_fn is a structure of tensors with matching keys
        and shapes of  this `extras`.
      max_input_length: maximum length of effective input. This is used to
        truncate the computation if the inputs have been allocated to a
        larger size. A scalar tensor.
      use_tpu: whether or not we are on TPU.
      aligned_end: A boolean indicating whether the sequence is aligned at
        the end.
  
    Returns:
      accumulate_state and the final state.
    """
    if cell_grad is None and _IsSingleTimeStep(inputs, max_input_length):
      # The seqlen length is staticly known as 1. Hence, we just need to
      # call cell_fn once without putting it into a loop.
      inputs = nest.map_structure(lambda x: array_ops.squeeze(x, axis=0), inputs)
      state1, _ = cell_fn(theta, state0, inputs)
      acc_state = nest.map_structure(lambda x: array_ops.expand_dims(x, axis=0),
                                     state1)
      return acc_state, state1
  
    # If cell_grad is not given, derives the gradient function from
    # cell_fn.
    cell_grad = _GetCellGrad(cell_fn, cell_grad)
  
    if extras is None:
      # Derives 'extras' so that we can allocate extras' accumulator.
      _, extras = cell_fn(theta, state0, _Index(inputs, 0))
      extras = nest.map_structure(array_ops.zeros_like, extras)
    else:
      _, actual = cell_fn(theta, state0, _Index(inputs, 0))
      _AssertIsCompatible(extras, actual)
  
    return _Recurrent(
        cell_fn=cell_fn,
        cell_grad=cell_grad,
        theta=theta,
        state0=state0,
        inputs=inputs,
        max_input_length=max_input_length,
        extras=extras,
        use_tpu=use_tpu,
        aligned_end=aligned_end).Compute()
function_tokens: def Recurrent ( theta , state0 , inputs , cell_fn , cell_grad = None , extras = None , max_input_length = None , use_tpu = False , aligned_end = False ) : if cell_grad is None and _IsSingleTimeStep ( inputs , max_input_length ) : # The seqlen length is staticly known as 1. Hence, we just need to # call cell_fn once without putting it into a loop. inputs = nest . map_structure ( lambda x : array_ops . squeeze ( x , axis = 0 ) , inputs ) state1 , _ = cell_fn ( theta , state0 , inputs ) acc_state = nest . map_structure ( lambda x : array_ops . expand_dims ( x , axis = 0 ) , state1 ) return acc_state , state1 # If cell_grad is not given, derives the gradient function from # cell_fn. cell_grad = _GetCellGrad ( cell_fn , cell_grad ) if extras is None : # Derives 'extras' so that we can allocate extras' accumulator. _ , extras = cell_fn ( theta , state0 , _Index ( inputs , 0 ) ) extras = nest . map_structure ( array_ops . zeros_like , extras ) else : _ , actual = cell_fn ( theta , state0 , _Index ( inputs , 0 ) ) _AssertIsCompatible ( extras , actual ) return _Recurrent ( cell_fn = cell_fn , cell_grad = cell_grad , theta = theta , state0 = state0 , inputs = inputs , max_input_length = max_input_length , extras = extras , use_tpu = use_tpu , aligned_end = aligned_end ) . Compute ( )