code: def draw_boxes_side_by_side(
      pred: Dict[str, Any],
      batch: Dict[str, Any],
      label_map: Dict[int, str],
  ) -> np.ndarray:
      """Side-by-side visualization of detection predictions and ground truth."""
  
      viz = []
  
      # unnormalizes images to be [0, 1]
      mean_rgb = np.reshape(
          np.array([0.48, 0.456, 0.406]), [1, 1, 1, 3]
      )
      std_rgb = np.reshape(
          np.array([0.229, 0.224, 0.225]), [1, 1, 1, 3]
      )
      imgs = ((batch["inputs"] * std_rgb + mean_rgb) * 255.0).astype(
          np.uint8
      )
  
      font = PIL.ImageFont.load_default()
  
      # iterates over images in the batch and makes visualizations
      for indx in range(imgs.shape[0]):
          h, w = batch["label"]["size"][indx]
  
          # first for ground truth
          gtim = PIL.Image.fromarray(imgs[indx])
          gtdraw = PIL.ImageDraw.Draw(gtim)
          for bb, cls, is_crowd in zip(
              batch["label"]["boxes"][indx],
              batch["label"]["labels"][indx],
              batch["label"]["is_crowd"][indx],
          ):
              if cls == 0:
                  continue  # dummy object.
  
              bcx, bcy, bw, bh = bb * [w, h, w, h]
              bb = [
                  bcx - bw / 2,
                  bcy - bh / 2,
                  bcx + bw / 2,
                  bcy + bh / 2,
              ]
              if is_crowd:
                  edgecolor = (255, 0, 0)
              else:
                  edgecolor = (255, 255, 0)
  
              gtdraw.rectangle(
                  bb, fill=None, outline=edgecolor, width=3
              )
              gtdraw.text(
                  [bb[0], max(bb[1] - 10, 0)],
                  label_map[cls],
                  font=font,
                  fill=(0, 0, 255),
              )
  
          # second for model predictions
          predim = PIL.Image.fromarray(imgs[indx])
          preddraw = PIL.ImageDraw.Draw(predim)
          pred_lbls = np.argmax(pred["pred_logits"], axis=-1)
          for bb, cls in zip(pred["pred_boxes"][indx], pred_lbls[indx]):
              h, w = batch["label"]["size"][indx]
              bcx, bcy, bw, bh = bb * [w, h, w, h]
              bb = [
                  bcx - bw / 2,
                  bcy - bh / 2,
                  bcx + bw / 2,
                  bcy + bh / 2,
              ]
              edgecolor = (0, 255, 0) if cls else (0, 150, 0)
              preddraw.rectangle(
                  bb,
                  fill=None,
                  outline=edgecolor,
                  width=3 if cls else 1,
              )
          # Separate loop for text to prevent occlusion of text by boxes:
          for bb, cls in zip(pred["pred_boxes"][indx], pred_lbls[indx]):
              if not cls:
                  continue
              h, w = batch["label"]["size"][indx]
              bcx, bcy, bw, bh = bb * [w, h, w, h]
              bb = [
                  bcx - bw / 2,
                  bcy - bh / 2,
                  bcx + bw / 2,
                  bcy + bh / 2,
              ]
              preddraw.text(
                  [bb[0], max(bb[1] - 10, 0)],
                  label_map[cls],
                  font=font,
                  fill=(0, 0, 255),
              )
  
          gtim_np = np.asarray(gtim)
          predim_np = np.asarray(predim)
          composite = np.concatenate([predim_np, gtim_np], axis=1)
  
          viz.append(composite)
      return np.stack(viz, axis=0)
  
imports: import copy
  import json
  import os
  from typing import Any, Dict, Optional, Set
  from absl import logging
  from flax import core
  from flax import optim
  from flax import traverse_util
  import jax
  from jax.example_libraries import optimizers
  import jax.numpy
  import numpy
  import PIL
  import PIL.ImageDraw
  import PIL.ImageFont
  from scenic.common_lib import image_utils
  from scenic.dataset_lib.coco_dataset import coco_eval
  from scenic.model_lib.base_models import box_utils
  from scenic.train_lib_deprecated import optimizers
  from scenic.train_lib_deprecated import train_utils
  import scipy.special
  import tensorflow
label_desc: Use image node_id 4 for calling a global function with example usage: draw_boxes_side_by_side(pred, batch, label_map) and returns: np