code: def build_graph(self, *inputs):
      inputs = dict(zip(self.input_names, inputs))
      if "gt_masks_packed" in inputs:
          gt_masks = tf.cast(
              unpackbits_masks(inputs.pop("gt_masks_packed")),
              tf.uint8,
              name="gt_masks",
          )
          inputs["gt_masks"] = gt_masks
  
      image = self.preprocess(inputs["image"])  # 1CHW
  
      features = self.backbone(image)
      anchor_inputs = {
          k: v for k, v in inputs.items() if k.startswith("anchor_")
      }
      proposals, rpn_losses = self.rpn(
          image, features, anchor_inputs
      )  # inputs?
  
      targets = [
          inputs[k]
          for k in ["gt_boxes", "gt_labels", "gt_masks"]
          if k in inputs
      ]
      gt_boxes_area = tf.reduce_mean(
          tf_area(inputs["gt_boxes"]), name="mean_gt_box_area"
      )
      add_moving_summary(gt_boxes_area)
      head_losses = self.roi_heads(image, features, proposals, targets)
  
      if self.training:
          wd_cost = regularize_cost(
              ".*/W",
              l2_regularizer(cfg.TRAIN.WEIGHT_DECAY),
              name="wd_cost",
          )
          total_cost = tf.add_n(
              rpn_losses + head_losses + [wd_cost], "total_cost"
          )
          add_moving_summary(total_cost, wd_cost)
          return total_cost
      else:
          # Check that the model defines the tensors it declares for inference
          # For existing models, they are defined in "fastrcnn_predictions(name_scope='output')"
          G = tf.get_default_graph()
          ns = G.get_name_scope()
          for name in self.get_inference_tensor_names()[1]:
              try:
                  name = "/".join([ns, name]) if ns else name
                  G.get_tensor_by_name(name + ":0")
              except KeyError:
                  raise KeyError(
                      "Your model does not define the tensor '{}' in inference context.".format(
                          name
                      )
                  )
  
imports: from tensorpack import tfv1
  from tensorpack import ModelDesc
  from tensorpack.models import GlobalAvgPooling, l2_regularizer, regularize_cost
  from tensorpack.tfutils import optimizer
  from tensorpack.tfutils.summary import add_moving_summary
  from config import config
  from data import get_all_anchors, get_all_anchors_fpn
  from utils.box_ops import area
  from .None import model_frcnn
  from .None import model_mrcnn
  from .backbone import image_preprocess, resnet_c4_backbone, resnet_conv5, resnet_fpn_backbone
  from .model_box import RPNAnchors, clip_boxes, crop_and_resize, roi_align
  from .model_cascade import CascadeRCNNHead
  from .model_fpn import fpn_model, generate_fpn_proposals, multilevel_roi_align, multilevel_rpn_losses
  from .model_frcnn import BoxProposals, FastRCNNHead, fastrcnn_outputs, fastrcnn_predictions, sample_fast_rcnn_targets
  from .model_mrcnn import maskrcnn_loss, maskrcnn_upXconv_head, unpackbits_masks
  from .model_rpn import generate_rpn_proposals, rpn_head, rpn_losses
label_desc: Use image node_id 4 for calling the GeneralizedRCNN obj's underlying member method code with example usage: obj.build_graph() and returns: total_cost