parameters: (dim_indices, conf, cells, c_prev, m_prev, new_output, new_state,
                 first_call)
docstring: Propagates through all the cells in dim_indices dimensions.
docstring_summary: Propagates through all the cells in dim_indices dimensions.
docstring_tokens: Propagates through all the cells in dim_indices dimensions .
function: def _propagate(dim_indices, conf, cells, c_prev, m_prev, new_output, new_state,
                 first_call):
    """Propagates through all the cells in dim_indices dimensions.
    """
    if len(dim_indices) == 0:
      return
  
    # Because of the way RNNCells are implemented, we take the last dimension
    # (H_{N-1}) out and feed it as the state of the RNN cell
    # (in `last_dim_output`).
    # The input of the cell (H_0 to H_{N-2}) are concatenated into `cell_inputs`
    if conf.num_dims > 1:
      ls_cell_inputs = [None] * (conf.num_dims - 1)
      for d in conf.dims[:-1]:
        if new_output[d.idx] is None:
          ls_cell_inputs[d.idx] = m_prev[d.idx]
        else:
          ls_cell_inputs[d.idx] = new_output[d.idx]
      cell_inputs = array_ops.concat(ls_cell_inputs, 1)
    else:
      cell_inputs = array_ops.zeros([m_prev[0].get_shape().as_list()[0], 0],
                                    m_prev[0].dtype)
  
    last_dim_output = (new_output[-1]
                       if new_output[-1] is not None else m_prev[-1])
  
    for i in dim_indices:
      d = conf.dims[i]
      if d.non_recurrent_fn:
        if conf.num_dims > 1:
          linear_args = array_ops.concat([cell_inputs, last_dim_output], 1)
        else:
          linear_args = last_dim_output
        with vs.variable_scope('non_recurrent' if conf.tied else
                               'non_recurrent/cell_{}'.format(i)):
          if conf.tied and not (first_call and i == dim_indices[0]):
            vs.get_variable_scope().reuse_variables()
  
          new_output[d.idx] = layers.fully_connected(
              linear_args,
              num_outputs=conf.num_units,
              activation_fn=d.non_recurrent_fn,
              weights_initializer=(vs.get_variable_scope().initializer or
                                   layers.initializers.xavier_initializer),
              weights_regularizer=vs.get_variable_scope().regularizer)
      else:
        if c_prev[i] is not None:
          cell_state = (c_prev[i], last_dim_output)
        else:
          # for GRU/RNN, the state is just the previous output
          cell_state = last_dim_output
  
        with vs.variable_scope('recurrent' if conf.tied else
                               'recurrent/cell_{}'.format(i)):
          if conf.tied and not (first_call and i == dim_indices[0]):
            vs.get_variable_scope().reuse_variables()
          cell = cells[i]
          new_output[d.idx], new_state[d.idx] = cell(cell_inputs, cell_state)
function_tokens: def _propagate ( dim_indices , conf , cells , c_prev , m_prev , new_output , new_state , first_call ) : if len ( dim_indices ) == 0 : return # Because of the way RNNCells are implemented, we take the last dimension # (H_{N-1}) out and feed it as the state of the RNN cell # (in `last_dim_output`). # The input of the cell (H_0 to H_{N-2}) are concatenated into `cell_inputs` if conf . num_dims > 1 : ls_cell_inputs = [ None ] * ( conf . num_dims - 1 ) for d in conf . dims [ : - 1 ] : if new_output [ d . idx ] is None : ls_cell_inputs [ d . idx ] = m_prev [ d . idx ] else : ls_cell_inputs [ d . idx ] = new_output [ d . idx ] cell_inputs = array_ops . concat ( ls_cell_inputs , 1 ) else : cell_inputs = array_ops . zeros ( [ m_prev [ 0 ] . get_shape ( ) . as_list ( ) [ 0 ] , 0 ] , m_prev [ 0 ] . dtype ) last_dim_output = ( new_output [ - 1 ] if new_output [ - 1 ] is not None else m_prev [ - 1 ] ) for i in dim_indices : d = conf . dims [ i ] if d . non_recurrent_fn : if conf . num_dims > 1 : linear_args = array_ops . concat ( [ cell_inputs , last_dim_output ] , 1 ) else : linear_args = last_dim_output with vs . variable_scope ( 'non_recurrent' if conf . tied else 'non_recurrent/cell_{}' . format ( i ) ) : if conf . tied and not ( first_call and i == dim_indices [ 0 ] ) : vs . get_variable_scope ( ) . reuse_variables ( ) new_output [ d . idx ] = layers . fully_connected ( linear_args , num_outputs = conf . num_units , activation_fn = d . non_recurrent_fn , weights_initializer = ( vs . get_variable_scope ( ) . initializer or layers . initializers . xavier_initializer ) , weights_regularizer = vs . get_variable_scope ( ) . regularizer ) else : if c_prev [ i ] is not None : cell_state = ( c_prev [ i ] , last_dim_output ) else : # for GRU/RNN, the state is just the previous output cell_state = last_dim_output with vs . variable_scope ( 'recurrent' if conf . tied else 'recurrent/cell_{}' . format ( i ) ) : if conf . tied and not ( first_call and i == dim_indices [ 0 ] ) : vs . get_variable_scope ( ) . reuse_variables ( ) cell = cells [ i ] new_output [ d . idx ] , new_state [ d . idx ] = cell ( cell_inputs , cell_state )