code: def _evaluate(
      self,
      model,
      data_loader,
      tokenizer,
      rouge1,
      rouge2,
      attn_id,
      max_decode_len,
      max_encode_len,
      beam_width,
      length_penalty,
  ):
      paddle.disable_static()
      model.eval()
  
      vocab = tokenizer.vocab
      eos_id = vocab[tokenizer.sep_token]
      sos_id = vocab[tokenizer.cls_token]
      pad_id = vocab[tokenizer.pad_token]
      unk_id = vocab[tokenizer.unk_token]
      vocab_size = len(vocab)
      evaluated_sentences_ids = []
      reference_sentences_ids = []
      logger.info("Evaluating...")
      for data in data_loader:
          (
              src_ids,
              src_tids,
              src_pids,
              _,
              _,
              _,
              _,
              _,
              _,
              _,
              _,
              raw_tgt_labels,
          ) = data  # never use target when infer
          # Use greedy_search_infilling or beam_search_infilling to get predictions
          output_ids = beam_search_infilling(
              model,
              src_ids,
              src_tids,
              eos_id=eos_id,
              sos_id=sos_id,
              attn_id=attn_id,
              pad_id=pad_id,
              unk_id=unk_id,
              vocab_size=vocab_size,
              max_decode_len=max_decode_len,
              max_encode_len=max_encode_len,
              beam_width=beam_width,
              length_penalty=length_penalty,
              tgt_type_id=1,
          )
  
          for ids in output_ids.tolist():
              if eos_id in ids:
                  ids = ids[: ids.index(eos_id)]
              evaluated_sentences_ids.append(ids[0])
  
          for ids in raw_tgt_labels.numpy().tolist():
              ids = ids[: ids.index(eos_id)]
              reference_sentences_ids.append(ids)
  
      score1 = rouge1.score(
          evaluated_sentences_ids, reference_sentences_ids
      )
      score2 = rouge2.score(
          evaluated_sentences_ids, reference_sentences_ids
      )
  
      logger.info(
          "Rouge-1: %.5f ,Rouge-2: %.5f" % (score1 * 100, score2 * 100)
      )
  
      evaluated_sentences = []
      reference_sentences = []
      for ids in reference_sentences_ids[:3]:
          reference_sentences.append(
              "".join(map(post_process, vocab.to_tokens(ids)))
          )
      for ids in evaluated_sentences_ids[:3]:
          evaluated_sentences.append(
              "".join(map(post_process, vocab.to_tokens(ids)))
          )
      logger.debug(reference_sentences)
      logger.debug(evaluated_sentences)
  
      model.train()
  
imports: import os
  import sys
  import shutil
  from copy import deepcopy
  import numpy
  import paddle
  import paddle.nn
  from paddle.io import DataLoader
  import paddlehub
  from paddlehub.common.logger import logger
  from paddlehub.module.module import moduleinfo
  from paddlenlp.datasets import MapDataset
  from paddlenlp.data import Stack, Tuple, Pad
  from paddlenlp.metrics import Rouge1, Rouge2
  from paddlenlp.transformers import ErnieTokenizer, ErnieForGeneration, LinearDecayWithWarmup
  from .encode import convert_example, after_padding
  from .decode import post_process, beam_search_infilling
  from .model import StackModel
label_desc: Use image node_id 5 for calling the ErnieGen obj's underlying member method code with example usage: obj._evaluate(model, data_loader, tokenizer, rouge1, rouge2, attn_id, max_decode_len, max_encode_len, beam_width, length_penalty) without return types