parameters: (encoder_inputs,
                           decoder_inputs_dict,
                           enc_cell,
                           dec_cells_dict,
                           num_encoder_symbols,
                           num_decoder_symbols_dict,
                           embedding_size,
                           feed_previous=False,
                           dtype=None,
                           scope=None)
return_statement: return outputs_dict, state_dict
docstring: One-to-many RNN sequence-to-sequence model (multi-task).
  
    This is a multi-task sequence-to-sequence model with one encoder and multiple
    decoders. Reference to multi-task sequence-to-sequence learning can be found
    here: http://arxiv.org/abs/1511.06114
  
    Args:
      encoder_inputs: A list of 1D int32 Tensors of shape [batch_size].
      decoder_inputs_dict: A dictionary mapping decoder name (string) to
        the corresponding decoder_inputs; each decoder_inputs is a list of 1D
        Tensors of shape [batch_size]; num_decoders is defined as
        len(decoder_inputs_dict).
      enc_cell: tf.nn.rnn_cell.RNNCell defining the encoder cell function and
        size.
      dec_cells_dict: A dictionary mapping encoder name (string) to an
        instance of tf.nn.rnn_cell.RNNCell.
      num_encoder_symbols: Integer; number of symbols on the encoder side.
      num_decoder_symbols_dict: A dictionary mapping decoder name (string) to an
        integer specifying number of symbols for the corresponding decoder;
        len(num_decoder_symbols_dict) must be equal to num_decoders.
      embedding_size: Integer, the length of the embedding vector for each symbol.
      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 of the initial state for both the encoder and encoder
        rnn cells (default: tf.float32).
      scope: VariableScope for the created subgraph; defaults to
        "one2many_rnn_seq2seq"
  
    Returns:
      A tuple of the form (outputs_dict, state_dict), where:
        outputs_dict: A mapping from decoder name (string) to a list of the same
          length as decoder_inputs_dict[name]; each element in the list is a 2D
          Tensors with shape [batch_size x num_decoder_symbol_list[name]]
          containing the generated outputs.
        state_dict: A mapping from decoder name (string) to the final state of the
          corresponding decoder RNN; it is a 2D Tensor of shape
          [batch_size x cell.state_size].
  
    Raises:
      TypeError: if enc_cell or any of the dec_cells are not instances of RNNCell.
      ValueError: if len(dec_cells) != len(decoder_inputs_dict).
docstring_summary: One-to-many RNN sequence-to-sequence model (multi-task).
docstring_tokens: One - to - many RNN sequence - to - sequence model ( multi - task ) .
function: def one2many_rnn_seq2seq(encoder_inputs,
                           decoder_inputs_dict,
                           enc_cell,
                           dec_cells_dict,
                           num_encoder_symbols,
                           num_decoder_symbols_dict,
                           embedding_size,
                           feed_previous=False,
                           dtype=None,
                           scope=None):
    """One-to-many RNN sequence-to-sequence model (multi-task).
  
    This is a multi-task sequence-to-sequence model with one encoder and multiple
    decoders. Reference to multi-task sequence-to-sequence learning can be found
    here: http://arxiv.org/abs/1511.06114
  
    Args:
      encoder_inputs: A list of 1D int32 Tensors of shape [batch_size].
      decoder_inputs_dict: A dictionary mapping decoder name (string) to
        the corresponding decoder_inputs; each decoder_inputs is a list of 1D
        Tensors of shape [batch_size]; num_decoders is defined as
        len(decoder_inputs_dict).
      enc_cell: tf.nn.rnn_cell.RNNCell defining the encoder cell function and
        size.
      dec_cells_dict: A dictionary mapping encoder name (string) to an
        instance of tf.nn.rnn_cell.RNNCell.
      num_encoder_symbols: Integer; number of symbols on the encoder side.
      num_decoder_symbols_dict: A dictionary mapping decoder name (string) to an
        integer specifying number of symbols for the corresponding decoder;
        len(num_decoder_symbols_dict) must be equal to num_decoders.
      embedding_size: Integer, the length of the embedding vector for each symbol.
      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 of the initial state for both the encoder and encoder
        rnn cells (default: tf.float32).
      scope: VariableScope for the created subgraph; defaults to
        "one2many_rnn_seq2seq"
  
    Returns:
      A tuple of the form (outputs_dict, state_dict), where:
        outputs_dict: A mapping from decoder name (string) to a list of the same
          length as decoder_inputs_dict[name]; each element in the list is a 2D
          Tensors with shape [batch_size x num_decoder_symbol_list[name]]
          containing the generated outputs.
        state_dict: A mapping from decoder name (string) to the final state of the
          corresponding decoder RNN; it is a 2D Tensor of shape
          [batch_size x cell.state_size].
  
    Raises:
      TypeError: if enc_cell or any of the dec_cells are not instances of RNNCell.
      ValueError: if len(dec_cells) != len(decoder_inputs_dict).
    """
    outputs_dict = {}
    state_dict = {}
  
    if not isinstance(enc_cell, rnn_cell_impl.RNNCell):
      raise TypeError("enc_cell is not an RNNCell: %s" % type(enc_cell))
    if set(dec_cells_dict) != set(decoder_inputs_dict):
      raise ValueError("keys of dec_cells_dict != keys of decodre_inputs_dict")
    for dec_cell in dec_cells_dict.values():
      if not isinstance(dec_cell, rnn_cell_impl.RNNCell):
        raise TypeError("dec_cell is not an RNNCell: %s" % type(dec_cell))
  
    with variable_scope.variable_scope(
        scope or "one2many_rnn_seq2seq", dtype=dtype) as scope:
      dtype = scope.dtype
  
      # Encoder.
      enc_cell = core_rnn_cell.EmbeddingWrapper(
          enc_cell,
          embedding_classes=num_encoder_symbols,
          embedding_size=embedding_size)
      _, encoder_state = rnn.static_rnn(enc_cell, encoder_inputs, dtype=dtype)
  
      # Decoder.
      for name, decoder_inputs in decoder_inputs_dict.items():
        num_decoder_symbols = num_decoder_symbols_dict[name]
        dec_cell = dec_cells_dict[name]
  
        with variable_scope.variable_scope("one2many_decoder_" + str(
            name)) as scope:
          dec_cell = core_rnn_cell.OutputProjectionWrapper(
              dec_cell, num_decoder_symbols)
          if isinstance(feed_previous, bool):
            outputs, state = embedding_rnn_decoder(
                decoder_inputs,
                encoder_state,
                dec_cell,
                num_decoder_symbols,
                embedding_size,
                feed_previous=feed_previous)
          else:
            # If feed_previous is a Tensor, we construct 2 graphs and use cond.
            def filled_embedding_rnn_decoder(feed_previous):
              """The current decoder with a fixed feed_previous parameter."""
              # pylint: disable=cell-var-from-loop
              reuse = None if feed_previous else True
              vs = variable_scope.get_variable_scope()
              with variable_scope.variable_scope(vs, reuse=reuse):
                outputs, state = embedding_rnn_decoder(
                    decoder_inputs,
                    encoder_state,
                    dec_cell,
                    num_decoder_symbols,
                    embedding_size,
                    feed_previous=feed_previous)
              # pylint: enable=cell-var-from-loop
              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: filled_embedding_rnn_decoder(True),
                lambda: filled_embedding_rnn_decoder(False))
            # Outputs length is the same as for decoder inputs.
            outputs_len = len(decoder_inputs)
            outputs = outputs_and_state[:outputs_len]
            state_list = outputs_and_state[outputs_len:]
            state = state_list[0]
            if nest.is_sequence(encoder_state):
              state = nest.pack_sequence_as(
                  structure=encoder_state, flat_sequence=state_list)
        outputs_dict[name] = outputs
        state_dict[name] = state
  
    return outputs_dict, state_dict
function_tokens: def one2many_rnn_seq2seq ( encoder_inputs , decoder_inputs_dict , enc_cell , dec_cells_dict , num_encoder_symbols , num_decoder_symbols_dict , embedding_size , feed_previous = False , dtype = None , scope = None ) : outputs_dict = { } state_dict = { } if not isinstance ( enc_cell , rnn_cell_impl . RNNCell ) : raise TypeError ( "enc_cell is not an RNNCell: %s" % type ( enc_cell ) ) if set ( dec_cells_dict ) != set ( decoder_inputs_dict ) : raise ValueError ( "keys of dec_cells_dict != keys of decodre_inputs_dict" ) for dec_cell in dec_cells_dict . values ( ) : if not isinstance ( dec_cell , rnn_cell_impl . RNNCell ) : raise TypeError ( "dec_cell is not an RNNCell: %s" % type ( dec_cell ) ) with variable_scope . variable_scope ( scope or "one2many_rnn_seq2seq" , dtype = dtype ) as scope : dtype = scope . dtype # Encoder. enc_cell = core_rnn_cell . EmbeddingWrapper ( enc_cell , embedding_classes = num_encoder_symbols , embedding_size = embedding_size ) _ , encoder_state = rnn . static_rnn ( enc_cell , encoder_inputs , dtype = dtype ) # Decoder. for name , decoder_inputs in decoder_inputs_dict . items ( ) : num_decoder_symbols = num_decoder_symbols_dict [ name ] dec_cell = dec_cells_dict [ name ] with variable_scope . variable_scope ( "one2many_decoder_" + str ( name ) ) as scope : dec_cell = core_rnn_cell . OutputProjectionWrapper ( dec_cell , num_decoder_symbols ) if isinstance ( feed_previous , bool ) : outputs , state = embedding_rnn_decoder ( decoder_inputs , encoder_state , dec_cell , num_decoder_symbols , embedding_size , feed_previous = feed_previous ) else : # If feed_previous is a Tensor, we construct 2 graphs and use cond. def filled_embedding_rnn_decoder ( feed_previous ) : """The current decoder with a fixed feed_previous parameter.""" # pylint: disable=cell-var-from-loop reuse = None if feed_previous else True vs = variable_scope . get_variable_scope ( ) with variable_scope . variable_scope ( vs , reuse = reuse ) : outputs , state = embedding_rnn_decoder ( decoder_inputs , encoder_state , dec_cell , num_decoder_symbols , embedding_size , feed_previous = feed_previous ) # pylint: enable=cell-var-from-loop 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 : filled_embedding_rnn_decoder ( True ) , lambda : filled_embedding_rnn_decoder ( False ) ) # Outputs length is the same as for decoder inputs. outputs_len = len ( decoder_inputs ) outputs = outputs_and_state [ : outputs_len ] state_list = outputs_and_state [ outputs_len : ] state = state_list [ 0 ] if nest . is_sequence ( encoder_state ) : state = nest . pack_sequence_as ( structure = encoder_state , flat_sequence = state_list ) outputs_dict [ name ] = outputs state_dict [ name ] = state return outputs_dict , state_dict