parameters: (subpath_sent_batch, seq_lens, dim, batch_size, is_train)
return_statement: return final_hidden, dim
docstring: Build a rnn along the given path and return the resulting path vector.
docstring_summary: Build a rnn along the given path and return the resulting path vector.
docstring_tokens: Build a rnn along the given path and return the resulting path vector .
function: def _create_rnn_along_subpath(subpath_sent_batch, seq_lens, dim, batch_size, is_train):
  	"""
  		Build a rnn along the given path and return the resulting path vector.
  	"""
  	# rnn cell
  	if FLAGS.bi:
  		cell_fw, cell_bw = _get_rnn_cell(dim, FLAGS.num_layers, is_train, FLAGS.dropout), \
  				_get_rnn_cell(dim, FLAGS.num_layers, is_train, FLAGS.dropout)
  	else:
  		cell = _get_rnn_cell(dim, FLAGS.num_layers, is_train, FLAGS.dropout)
  	# rnn layer
  	# NOTE that rnn is doing dynamic batching now so outputs will be tailed by zero vectors in a batch
  	if FLAGS.bi:
  		rnn_outputs, rnn_final_states = tf.nn.bidirectional_dynamic_rnn(cell_fw, cell_bw, subpath_sent_batch, dtype=tf.float32, sequence_length=seq_lens)
  		rnn_outputs = tf.concat(2, rnn_outputs) # the original is a tuple, we need to concatenate them
  		rnn_final_states_fw, rnn_final_states_bw = rnn_final_states
  		rnn_final_state = tf.concat(1, [rnn_final_states_fw[-1][1], rnn_final_states_bw[-1][1]])
  		dim = 2*dim
  	else:
  		rnn_outputs, rnn_final_states = tf.nn.dynamic_rnn(cell, subpath_sent_batch, dtype=tf.float32, sequence_length=seq_lens)
  		# rnn_final_states is tuple of tuple for LSTM, outputs is a tensor [batch_size, sent_len, dim]
  		rnn_final_state = rnn_final_states[-1][1]
  
  	# [optional] add pooling or attention layer
  	if FLAGS.pool:
  		final_hidden = tf.map_fn(lambda idx: max_over_time(rnn_outputs, idx, seq_lens), tf.range(0, batch_size), dtype=tf.float32)
  	elif FLAGS.attn:
  		# attention layer
  		attention, attn_final_state = _create_attention_layer(rnn_outputs, rnn_final_state, seq_lens, dim, batch_size)
  		final_hidden = attn_final_state
  	else:
  		final_hidden = rnn_final_state
  	return final_hidden, dim
function_tokens: def _create_rnn_along_subpath ( subpath_sent_batch , seq_lens , dim , batch_size , is_train ) : # rnn cell if FLAGS . bi : cell_fw , cell_bw = _get_rnn_cell ( dim , FLAGS . num_layers , is_train , FLAGS . dropout ) , _get_rnn_cell ( dim , FLAGS . num_layers , is_train , FLAGS . dropout ) else : cell = _get_rnn_cell ( dim , FLAGS . num_layers , is_train , FLAGS . dropout ) # rnn layer # NOTE that rnn is doing dynamic batching now so outputs will be tailed by zero vectors in a batch if FLAGS . bi : rnn_outputs , rnn_final_states = tf . nn . bidirectional_dynamic_rnn ( cell_fw , cell_bw , subpath_sent_batch , dtype = tf . float32 , sequence_length = seq_lens ) rnn_outputs = tf . concat ( 2 , rnn_outputs ) # the original is a tuple, we need to concatenate them rnn_final_states_fw , rnn_final_states_bw = rnn_final_states rnn_final_state = tf . concat ( 1 , [ rnn_final_states_fw [ - 1 ] [ 1 ] , rnn_final_states_bw [ - 1 ] [ 1 ] ] ) dim = 2 * dim else : rnn_outputs , rnn_final_states = tf . nn . dynamic_rnn ( cell , subpath_sent_batch , dtype = tf . float32 , sequence_length = seq_lens ) # rnn_final_states is tuple of tuple for LSTM, outputs is a tensor [batch_size, sent_len, dim] rnn_final_state = rnn_final_states [ - 1 ] [ 1 ] # [optional] add pooling or attention layer if FLAGS . pool : final_hidden = tf . map_fn ( lambda idx : max_over_time ( rnn_outputs , idx , seq_lens ) , tf . range ( 0 , batch_size ) , dtype = tf . float32 ) elif FLAGS . attn : # attention layer attention , attn_final_state = _create_attention_layer ( rnn_outputs , rnn_final_state , seq_lens , dim , batch_size ) final_hidden = attn_final_state else : final_hidden = rnn_final_state return final_hidden , dim