code: def viz_cam(model_file, data_dir):
      ds = get_data("val")
      pred_config = PredictConfig(
          model=Model(),
          session_init=SmartInit(model_file),
          input_names=["input", "label"],
          output_names=[
              "wrong-top1",
              "group3new/bnlast/Relu",
              "linearnew/W",
          ],
          return_input=True,
      )
      meta = dataset.ILSVRCMeta().get_synset_words_1000()
  
      pred = SimpleDatasetPredictor(pred_config, ds)
      cnt = 0
      for inp, outp in pred.get_result():
          images, labels = inp
          wrongs, convmaps, W = outp
          batch = wrongs.shape[0]
          for i in range(batch):
              if wrongs[i]:
                  continue
              weight = W[:, [labels[i]]].T  # 512x1
              convmap = convmaps[i, :, :, :]  # 512xhxw
              mergedmap = np.matmul(
                  weight, convmap.reshape((512, -1))
              ).reshape(14, 14)
              mergedmap = cv2.resize(mergedmap, (224, 224))
              heatmap = viz.intensity_to_rgb(mergedmap, normalize=True)
              blend = images[i] * 0.5 + heatmap * 0.5
              concat = np.concatenate(
                  (images[i], heatmap, blend), axis=1
              )
  
              classname = meta[labels[i]].split(",")[0]
              cv2.imwrite("cam{}-{}.jpg".format(cnt, classname), concat)
              cnt += 1
              if cnt == 500:
                  return
  
imports: import argparse
  import multiprocessing
  import numpy
  import os
  import sys
  import cv2
  import tensorflow
  from tensorpack import *
  from tensorpack.dataflow import dataset
  from tensorpack.tfutils import gradproc, optimizer
  from tensorpack.tfutils.summary import *
  from tensorpack.utils import viz
  from tensorpack.utils.gpu import get_num_gpu
  from imagenet_utils import ImageNetModel, fbresnet_augmentor
  from resnet_model import preresnet_basicblock, preresnet_group
label_desc: Use image node_id 3 for calling a global function with example usage: viz_cam(model_file, data_dir) without return types