parameters: (encoder_inputs,
                                 decoder_inputs,
                                 cell,
                                 num_symbols,
                                 embedding_size,
                                 num_decoder_symbols=None,
                                 output_projection=None,
                                 feed_previous=False,
                                 dtype=None,
                                 scope=None)
docstring: Embedding RNN sequence-to-sequence model with tied (shared) parameters.
  
    This model first embeds encoder_inputs by a newly created embedding (of shape
    [num_symbols x input_size]). Then it runs an RNN to encode embedded
    encoder_inputs into a state vector. Next, it embeds decoder_inputs using
    the same embedding. Then it runs RNN decoder, initialized with the last
    encoder state, on embedded decoder_inputs. The decoder output is over symbols
    from 0 to num_decoder_symbols - 1 if num_decoder_symbols is none; otherwise it
    is over 0 to num_symbols - 1.
  
    Args:
      encoder_inputs: A list of 1D int32 Tensors of shape [batch_size].
      decoder_inputs: A list of 1D int32 Tensors of shape [batch_size].
      cell: tf.nn.rnn_cell.RNNCell defining the cell function and size.
      num_symbols: Integer; number of symbols for both encoder and decoder.
      embedding_size: Integer, the length of the embedding vector for each symbol.
      num_decoder_symbols: Integer; number of output symbols for decoder. If
        provided, the decoder output is over symbols 0 to num_decoder_symbols - 1.
        Otherwise, decoder output is over symbols 0 to num_symbols - 1. Note that
        this assumes that the vocabulary is set up such that the first
        num_decoder_symbols of num_symbols are part of decoding.
      output_projection: None or a pair (W, B) of output projection weights and
        biases; W has shape [output_size x num_symbols] and B has
        shape [num_symbols]; if provided and feed_previous=True, each
        fed previous output will first be multiplied by W and added B.
      feed_previous: Boolean or scalar Boolean Tensor; if True, only the first
        of decoder_inputs will be used (the "GO" symbol), and all other decoder
        inputs will be taken from previous outputs (as in embedding_rnn_decoder).
        If False, decoder_inputs are used as given (the standard decoder case).
      dtype: The dtype to use for the initial RNN states (default: tf.float32).
      scope: VariableScope for the created subgraph; defaults to
        "embedding_tied_rnn_seq2seq".
  
    Returns:
      A tuple of the form (outputs, state), where:
        outputs: A list of the same length as decoder_inputs of 2D Tensors with
          shape [batch_size x output_symbols] containing the generated
          outputs where output_symbols = num_decoder_symbols if
          num_decoder_symbols is not None otherwise output_symbols = num_symbols.
        state: The state of each decoder cell at the final time-step.
          It is a 2D Tensor of shape [batch_size x cell.state_size].
  
    Raises:
      ValueError: When output_projection has the wrong shape.
docstring_summary: Embedding RNN sequence-to-sequence model with tied (shared) parameters.
docstring_tokens: Embedding RNN sequence - to - sequence model with tied ( shared ) parameters .
function: def embedding_tied_rnn_seq2seq(encoder_inputs,
                                 decoder_inputs,
                                 cell,
                                 num_symbols,
                                 embedding_size,
                                 num_decoder_symbols=None,
                                 output_projection=None,
                                 feed_previous=False,
                                 dtype=None,
                                 scope=None):
    """Embedding RNN sequence-to-sequence model with tied (shared) parameters.
  
    This model first embeds encoder_inputs by a newly created embedding (of shape
    [num_symbols x input_size]). Then it runs an RNN to encode embedded
    encoder_inputs into a state vector. Next, it embeds decoder_inputs using
    the same embedding. Then it runs RNN decoder, initialized with the last
    encoder state, on embedded decoder_inputs. The decoder output is over symbols
    from 0 to num_decoder_symbols - 1 if num_decoder_symbols is none; otherwise it
    is over 0 to num_symbols - 1.
  
    Args:
      encoder_inputs: A list of 1D int32 Tensors of shape [batch_size].
      decoder_inputs: A list of 1D int32 Tensors of shape [batch_size].
      cell: tf.nn.rnn_cell.RNNCell defining the cell function and size.
      num_symbols: Integer; number of symbols for both encoder and decoder.
      embedding_size: Integer, the length of the embedding vector for each symbol.
      num_decoder_symbols: Integer; number of output symbols for decoder. If
        provided, the decoder output is over symbols 0 to num_decoder_symbols - 1.
        Otherwise, decoder output is over symbols 0 to num_symbols - 1. Note that
        this assumes that the vocabulary is set up such that the first
        num_decoder_symbols of num_symbols are part of decoding.
      output_projection: None or a pair (W, B) of output projection weights and
        biases; W has shape [output_size x num_symbols] and B has
        shape [num_symbols]; if provided and feed_previous=True, each
        fed previous output will first be multiplied by W and added B.
      feed_previous: Boolean or scalar Boolean Tensor; if True, only the first
        of decoder_inputs will be used (the "GO" symbol), and all other decoder
        inputs will be taken from previous outputs (as in embedding_rnn_decoder).
        If False, decoder_inputs are used as given (the standard decoder case).
      dtype: The dtype to use for the initial RNN states (default: tf.float32).
      scope: VariableScope for the created subgraph; defaults to
        "embedding_tied_rnn_seq2seq".
  
    Returns:
      A tuple of the form (outputs, state), where:
        outputs: A list of the same length as decoder_inputs of 2D Tensors with
          shape [batch_size x output_symbols] containing the generated
          outputs where output_symbols = num_decoder_symbols if
          num_decoder_symbols is not None otherwise output_symbols = num_symbols.
        state: The state of each decoder cell at the final time-step.
          It is a 2D Tensor of shape [batch_size x cell.state_size].
  
    Raises:
      ValueError: When output_projection has the wrong shape.
    """
    with variable_scope.variable_scope(
        scope or "embedding_tied_rnn_seq2seq", dtype=dtype) as scope:
      dtype = scope.dtype
  
      if output_projection is not None:
        proj_weights = ops.convert_to_tensor(output_projection[0], dtype=dtype)
        proj_weights.get_shape().assert_is_compatible_with([None, num_symbols])
        proj_biases = ops.convert_to_tensor(output_projection[1], dtype=dtype)
        proj_biases.get_shape().assert_is_compatible_with([num_symbols])
  
      embedding = variable_scope.get_variable(
          "embedding", [num_symbols, embedding_size], dtype=dtype)
  
      emb_encoder_inputs = [
          embedding_ops.embedding_lookup(embedding, x) for x in encoder_inputs
      ]
      emb_decoder_inputs = [
          embedding_ops.embedding_lookup(embedding, x) for x in decoder_inputs
      ]
  
      output_symbols = num_symbols
      if num_decoder_symbols is not None:
        output_symbols = num_decoder_symbols
      if output_projection is None:
        cell = core_rnn_cell.OutputProjectionWrapper(cell, output_symbols)
  
      if isinstance(feed_previous, bool):
        loop_function = _extract_argmax_and_embed(embedding, output_projection,
                                                  True) if feed_previous else None
        return tied_rnn_seq2seq(
            emb_encoder_inputs,
            emb_decoder_inputs,
            cell,
            loop_function=loop_function,
            dtype=dtype)
  
      # If feed_previous is a Tensor, we construct 2 graphs and use cond.
      def decoder(feed_previous_bool):
        loop_function = _extract_argmax_and_embed(
            embedding, output_projection, False) if feed_previous_bool else None
        reuse = None if feed_previous_bool else True
        with variable_scope.variable_scope(
            variable_scope.get_variable_scope(), reuse=reuse):
          outputs, state = tied_rnn_seq2seq(
              emb_encoder_inputs,
              emb_decoder_inputs,
              cell,
              loop_function=loop_function,
              dtype=dtype)
          state_list = [state]
          if nest.is_sequence(state):
            state_list = nest.flatten(state)
          return outputs + state_list
  
      outputs_and_state = control_flow_ops.cond(feed_previous,
                                                lambda: decoder(True),
                                                lambda: decoder(False))
      outputs_len = len(decoder_inputs)  # Outputs length same as decoder inputs.
      state_list = outputs_and_state[outputs_len:]
      state = state_list[0]
      # Calculate zero-state to know it's structure.
      static_batch_size = encoder_inputs[0].get_shape()[0]
      for inp in encoder_inputs[1:]:
        static_batch_size.merge_with(inp.get_shape()[0])
      batch_size = static_batch_size.value
      if batch_size is None:
        batch_size = array_ops.shape(encoder_inputs[0])[0]
      zero_state = cell.zero_state(batch_size, dtype)
      if nest.is_sequence(zero_state):
        state = nest.pack_sequence_as(
            structure=zero_state, flat_sequence=state_list)
      return outputs_and_state[:outputs_len], state
function_tokens: def embedding_tied_rnn_seq2seq ( encoder_inputs , decoder_inputs , cell , num_symbols , embedding_size , num_decoder_symbols = None , output_projection = None , feed_previous = False , dtype = None , scope = None ) : with variable_scope . variable_scope ( scope or "embedding_tied_rnn_seq2seq" , dtype = dtype ) as scope : dtype = scope . dtype if output_projection is not None : proj_weights = ops . convert_to_tensor ( output_projection [ 0 ] , dtype = dtype ) proj_weights . get_shape ( ) . assert_is_compatible_with ( [ None , num_symbols ] ) proj_biases = ops . convert_to_tensor ( output_projection [ 1 ] , dtype = dtype ) proj_biases . get_shape ( ) . assert_is_compatible_with ( [ num_symbols ] ) embedding = variable_scope . get_variable ( "embedding" , [ num_symbols , embedding_size ] , dtype = dtype ) emb_encoder_inputs = [ embedding_ops . embedding_lookup ( embedding , x ) for x in encoder_inputs ] emb_decoder_inputs = [ embedding_ops . embedding_lookup ( embedding , x ) for x in decoder_inputs ] output_symbols = num_symbols if num_decoder_symbols is not None : output_symbols = num_decoder_symbols if output_projection is None : cell = core_rnn_cell . OutputProjectionWrapper ( cell , output_symbols ) if isinstance ( feed_previous , bool ) : loop_function = _extract_argmax_and_embed ( embedding , output_projection , True ) if feed_previous else None return tied_rnn_seq2seq ( emb_encoder_inputs , emb_decoder_inputs , cell , loop_function = loop_function , dtype = dtype ) # If feed_previous is a Tensor, we construct 2 graphs and use cond. def decoder ( feed_previous_bool ) : loop_function = _extract_argmax_and_embed ( embedding , output_projection , False ) if feed_previous_bool else None reuse = None if feed_previous_bool else True with variable_scope . variable_scope ( variable_scope . get_variable_scope ( ) , reuse = reuse ) : outputs , state = tied_rnn_seq2seq ( emb_encoder_inputs , emb_decoder_inputs , cell , loop_function = loop_function , dtype = dtype ) state_list = [ state ] if nest . is_sequence ( state ) : state_list = nest . flatten ( state ) return outputs + state_list outputs_and_state = control_flow_ops . cond ( feed_previous , lambda : decoder ( True ) , lambda : decoder ( False ) ) outputs_len = len ( decoder_inputs ) # Outputs length same as decoder inputs. state_list = outputs_and_state [ outputs_len : ] state = state_list [ 0 ] # Calculate zero-state to know it's structure. static_batch_size = encoder_inputs [ 0 ] . get_shape ( ) [ 0 ] for inp in encoder_inputs [ 1 : ] : static_batch_size . merge_with ( inp . get_shape ( ) [ 0 ] ) batch_size = static_batch_size . value if batch_size is None : batch_size = array_ops . shape ( encoder_inputs [ 0 ] ) [ 0 ] zero_state = cell . zero_state ( batch_size , dtype ) if nest . is_sequence ( zero_state ) : state = nest . pack_sequence_as ( structure = zero_state , flat_sequence = state_list ) return outputs_and_state [ : outputs_len ] , state