class_docstr: A callback that runs evaluation once a while.
  It supports multi-gpu evaluation.
class_docstr_tok: ["A","callback","that","runs","evaluation","once","a","while",".","It","supports","multi-gpu","evaluation","."]
code: def _setup_graph(self):
      num_gpu = cfg.TRAIN.NUM_GPUS
      if cfg.TRAINER == "replicated":
          # TF bug in version 1.11, 1.12: https://github.com/tensorflow/tensorflow/issues/22750
          buggy_tf = get_tf_version_tuple() in [(1, 11), (1, 12)]
  
          # Use two predictor threads per GPU to get better throughput
          self.num_predictor = num_gpu if buggy_tf else num_gpu * 2
          self.predictors = [
              self._build_predictor(k % num_gpu)
              for k in range(self.num_predictor)
          ]
          self.dataflows = [
              get_eval_dataflow(
                  self._eval_dataset,
                  shard=k,
                  num_shards=self.num_predictor,
              )
              for k in range(self.num_predictor)
          ]
      else:
          # Only eval on the first machine,
          # Because evaluation assumes that all horovod workers share the filesystem.
          # Alternatively, can eval on all ranks and use allgather, but allgather sometimes hangs
          self._horovod_run_eval = hvd.rank() == hvd.local_rank()
          if self._horovod_run_eval:
              self.predictor = self._build_predictor(0)
              self.dataflow = get_eval_dataflow(
                  self._eval_dataset,
                  shard=hvd.local_rank(),
                  num_shards=hvd.local_size(),
              )
  
          self.barrier = hvd.allreduce(tfv1.random_normal(shape=[1]))
  
imports: import itertools
  import json
  import numpy
  import os
  import sys
  from collections import namedtuple
  from concurrent.futures import ThreadPoolExecutor
  from contextlib import ExitStack
  import cv2
  import pycocotools.mask
  import tqdm
  from scipy import interpolate
  from tensorpack.callbacks import Callback
  from tensorpack.tfutils.common import get_tf_version_tuple
  from tensorpack.utils import logger, get_tqdm
  from common import CustomResize, clip_boxes
  from config import config
  from data import get_eval_dataflow
  from dataset import DatasetRegistry
  from tensorpack.compat import tfv1
label_desc: Use image node_id 2 for calling the EvalCallback obj's underlying member method code with example usage: obj._setup_graph() without return types