code: def build_model(batch, train_data, lambdas):
      """
      This function is basically the same as build_model() in
      baseline_seq2seq_attn.py, except the
      InterpolateDecoder and InterpolateHelper.
      """
      batch_size = tf.shape(batch["target_length"])[0]
  
      source_embedder = tx.modules.WordEmbedder(
          vocab_size=train_data.source_vocab.size,
          hparams=config_model.embedder,
      )
  
      encoder = tx.modules.BidirectionalRNNEncoder(
          hparams=config_model.encoder
      )
  
      enc_outputs, _ = encoder(
          source_embedder(batch["source_text_ids"])
      )
  
      target_embedder = tx.modules.WordEmbedder(
          vocab_size=train_data.target_vocab.size,
          hparams=config_model.embedder,
      )
  
      decoder = InterpolationDecoder(
          memory=tf.concat(enc_outputs, axis=2),
          memory_sequence_length=batch["source_length"],
          vocab_size=train_data.target_vocab.size,
          hparams=config_model.decoder,
      )
  
      start_tokens = (
          tf.ones_like(batch["target_length"])
          * train_data.target_vocab.bos_token_id
      )
      helper = InterpolationHelper(
          embedding=target_embedder,
          start_tokens=start_tokens,
          end_token=train_data.target_vocab.eos_token_id,
          reward_metric=config_data.eval_metric,
          vocab=train_data.target_vocab,
          ground_truth=batch["target_text_ids"][:, 1:],
          ground_truth_length=batch["target_length"] - 1,
          lambdas=lambdas,
      )
  
      training_outputs, _, training_length = decoder(
          helper=helper,
          initial_state=decoder.zero_state(
              batch_size=batch_size, dtype=tf.float32
          ),
          max_decoding_length=60,
      )
  
      train_op = tx.core.get_train_op(
          tx.losses.sequence_sparse_softmax_cross_entropy(
              labels=training_outputs.sample_id,
              logits=training_outputs.logits,
              sequence_length=training_length,
          ),
          hparams=config_model.opt,
      )
  
      beam_search_outputs, _, _ = tx.modules.beam_search_decode(
          decoder_or_cell=decoder,
          embedding=target_embedder,
          start_tokens=start_tokens,
          end_token=train_data.target_vocab.eos_token_id,
          beam_width=config_model.beam_width,
          max_decoding_length=60,
      )
  
      return train_op, beam_search_outputs
  
file_path: texar/examples/seq2seq_exposure_bias/interpolation_main.py
imports: import importlib
  from io import open
  import tensorflow
  import texar.tf
  import numpy
  from interpolation_decoder import InterpolationDecoder
  from interpolation_helper import InterpolationHelper
  from rouge import Rouge
label_desc: Use image node_id 1 for calling a global function with example usage: build_model(batch, train_data, lambdas) and returns: train_op,  beam_search_outputs