code: def __init__(
      self,
      fig_size,
      feat_size,
      steps,
      scales,
      aspect_ratios,
      scale_xy=0.1,
      scale_wh=0.2,
  ):
      self.feat_size = feat_size
      self.fig_size = fig_size
  
      self.scale_xy_ = scale_xy
      self.scale_wh_ = scale_wh
  
      # According to https://github.com/weiliu89/caffe
      # Calculation method slightly different from paper
      self.steps = steps
      self.scales = scales
  
      fk = fig_size / np.array(steps)
      self.aspect_ratios = aspect_ratios
  
      self.default_boxes = []
      # size of feature and number of feature
      for idx, sfeat in enumerate(self.feat_size):
          sk1 = scales[idx] / fig_size
          sk2 = scales[idx + 1] / fig_size
          sk3 = sqrt(sk1 * sk2)
          all_sizes = [(sk1, sk1), (sk3, sk3)]
  
          for alpha in aspect_ratios[idx]:
              w, h = sk1 * sqrt(alpha), sk1 / sqrt(alpha)
              all_sizes.append((w, h))
              all_sizes.append((h, w))
          for w, h in all_sizes:
              for i, j in itertools.product(range(sfeat), repeat=2):
                  cx, cy = (j + 0.5) / fk[idx], (i + 0.5) / fk[idx]
                  self.default_boxes.append((cx, cy, w, h))
  
      self.dboxes = torch.tensor(self.default_boxes, dtype=torch.float)
      self.dboxes.clamp_(min=0, max=1)
      # For IoU calculation
      self.dboxes_ltrb = self.dboxes.clone()
      self.dboxes_ltrb[:, 0] = (
          self.dboxes[:, 0] - 0.5 * self.dboxes[:, 2]
      )
      self.dboxes_ltrb[:, 1] = (
          self.dboxes[:, 1] - 0.5 * self.dboxes[:, 3]
      )
      self.dboxes_ltrb[:, 2] = (
          self.dboxes[:, 0] + 0.5 * self.dboxes[:, 2]
      )
      self.dboxes_ltrb[:, 3] = (
          self.dboxes[:, 1] + 0.5 * self.dboxes[:, 3]
      )
  
imports: import torch
  import torchvision.transforms
  import torch.utils.data
  from PIL import Image
  import os
  import numpy
  import random
  import itertools
  import torch.nn.functional
  import json
  import time
  import bz2
  import pickle
  from math import sqrt
label_desc: Use image node_id 1 to create a new DefaultBoxes object from inherited base classes: object with example: obj = DefaultBoxes(fig_size, feat_size, steps, scales, aspect_ratios, scale_xy, scale_wh)