code: def build_graph(self, state, action, futurereward, action_prob):
      logits, value = self._get_NN_prediction(state)
      value = tf.squeeze(value, [1], name="pred_value")  # (B,)
      policy = tf.nn.softmax(logits, name="policy")
      if not self.training:
          return
      log_probs = tf.log(policy + 1e-6)
  
      log_pi_a_given_s = tf.reduce_sum(
          log_probs * tf.one_hot(action, NUM_ACTIONS), 1
      )
      advantage = tf.subtract(
          tf.stop_gradient(value), futurereward, name="advantage"
      )
  
      pi_a_given_s = tf.reduce_sum(
          policy * tf.one_hot(action, NUM_ACTIONS), 1
      )  # (B,)
      importance = tf.stop_gradient(
          tf.clip_by_value(pi_a_given_s / (action_prob + 1e-8), 0, 10)
      )
  
      policy_loss = tf.reduce_sum(
          log_pi_a_given_s * advantage * importance, name="policy_loss"
      )
      xentropy_loss = tf.reduce_sum(
          policy * log_probs, name="xentropy_loss"
      )
      value_loss = tf.nn.l2_loss(
          value - futurereward, name="value_loss"
      )
  
      pred_reward = tf.reduce_mean(value, name="predict_reward")
      advantage = tf.sqrt(
          tf.reduce_mean(tf.square(advantage)), name="rms_advantage"
      )
      entropy_beta = tf.get_variable(
          "entropy_beta",
          shape=[],
          initializer=tf.constant_initializer(0.01),
          trainable=False,
      )
      cost = tf.add_n(
          [policy_loss, xentropy_loss * entropy_beta, value_loss]
      )
      cost = tf.truediv(
          cost,
          tf.cast(tf.shape(futurereward)[0], tf.float32),
          name="cost",
      )
      summary.add_moving_summary(
          policy_loss,
          xentropy_loss,
          value_loss,
          pred_reward,
          advantage,
          cost,
          tf.reduce_mean(importance, name="importance"),
      )
      return cost
  
imports: import argparse
  import cv2
  import gym
  import multiprocessing
  import numpy
  import os
  import sys
  import uuid
  import tensorflow
  from six.moves import queue
  from concurrent import futures
  from tensorpack import *
  from tensorpack.tfutils.gradproc import MapGradient, SummaryGradient
  from tensorpack.utils.concurrency import ensure_proc_terminate, start_proc_mask_signal
  from tensorpack.utils.gpu import get_num_gpu
  from tensorpack.utils.serialize import dumps
  from atari_wrapper import FireResetEnv, FrameStack, LimitLength, MapState
  from common import Evaluator, eval_model_multithread, play_n_episodes
  from simulator import SimulatorMaster, SimulatorProcess, TransitionExperience
label_desc: Use image node_id 3 for calling the Model obj's underlying member method code with example usage: obj.build_graph(state, action, futurereward, action_prob) and returns: cost