code: def run_internal_eval(
      eval_model,
      eval_sess,
      model_dir,
      hparams,
      summary_writer,
      use_test_set=True,
      dev_eval_iterator_feed_dict=None,
      test_eval_iterator_feed_dict=None,
  ):
      """Compute internal evaluation (perplexity) for both dev / test.
  
      Computes development and testing perplexities for given model.
  
      Args:
        eval_model: Evaluation model for which to compute perplexities.
        eval_sess: Evaluation TensorFlow session.
        model_dir: Directory from which to load evaluation model from.
        hparams: Model hyper-parameters.
        summary_writer: Summary writer for logging metrics to TensorBoard.
        use_test_set: Computes testing perplexity if true; does not otherwise.
          Note that the development perplexity is always computed regardless of
          value of this parameter.
        dev_eval_iterator_feed_dict: Feed dictionary for a TensorFlow session.
          Can be used to pass in additional inputs necessary for running the
          development evaluation.
        test_eval_iterator_feed_dict: Feed dictionary for a TensorFlow session.
          Can be used to pass in additional inputs necessary for running the
          testing evaluation.
      Returns:
        Pair containing development perplexity and testing perplexity, in this
        order.
      """
      if dev_eval_iterator_feed_dict is None:
          dev_eval_iterator_feed_dict = {}
      if test_eval_iterator_feed_dict is None:
          test_eval_iterator_feed_dict = {}
      with eval_model.graph.as_default():
          (
              loaded_eval_model,
              global_step,
          ) = model_helper.create_or_load_model(
              eval_model.model, model_dir, eval_sess, "eval"
          )
  
      dev_src_file = "%s.%s" % (hparams.dev_prefix, hparams.src)
      dev_tgt_file = "%s.%s" % (hparams.dev_prefix, hparams.tgt)
      dev_eval_iterator_feed_dict[
          eval_model.src_file_placeholder
      ] = dev_src_file
      dev_eval_iterator_feed_dict[
          eval_model.tgt_file_placeholder
      ] = dev_tgt_file
  
      dev_ppl = _internal_eval(
          loaded_eval_model,
          global_step,
          eval_sess,
          eval_model.iterator,
          dev_eval_iterator_feed_dict,
          summary_writer,
          "dev",
      )
      test_ppl = None
      if use_test_set and hparams.test_prefix:
          test_src_file = "%s.%s" % (hparams.test_prefix, hparams.src)
          test_tgt_file = "%s.%s" % (hparams.test_prefix, hparams.tgt)
          test_eval_iterator_feed_dict[
              eval_model.src_file_placeholder
          ] = test_src_file
          test_eval_iterator_feed_dict[
              eval_model.tgt_file_placeholder
          ] = test_tgt_file
          test_ppl = _internal_eval(
              loaded_eval_model,
              global_step,
              eval_sess,
              eval_model.iterator,
              test_eval_iterator_feed_dict,
              summary_writer,
              "test",
          )
      return dev_ppl, test_ppl
  
imports: from __future__ import print_function
  import math
  import os
  import random
  import time
  import tensorflow
  from .None import inference, gnmt_model
  from .gnmt import attention_model, model
  from .gnmt import model_helper
  from .gnmt.utils import nmt_utils, misc_utils
label_desc: Use image node_id 2 for calling a global function with example usage: run_internal_eval(eval_model, eval_sess, model_dir, hparams, summary_writer, use_test_set, dev_eval_iterator_feed_dict, test_eval_iterator_feed_dict) and returns: dev_ppl,  test_ppl