code: def qufpn_config(min_level, max_level, weight_method=None):
      """A dynamic quad fpn config that can adapt to different min/max levels."""
      # It extends the idea of BiFPN, and has four paths:
      #   (up_down -> bottom_up) + (bottom_up -> up_down).
      # See test for an example for level 2 and 7.
      p = hparams_config.Config()
      p.weight_method = weight_method or "fastattn"
      p.quad_method = "fastattn"
      num_levels = max_level - min_level + 1
      node_ids = {min_level + i: [i] for i in range(num_levels)}
      level_last_id = lambda level: node_ids[level][-1]
      level_all_ids = lambda level: node_ids[level]
      level_first_id = lambda level: node_ids[level][0]
      id_cnt = itertools.count(num_levels)
  
      p.nodes = []
      for i in range(max_level - 1, min_level - 1, -1):
          # top-down path 1.
          p.nodes.append(
              {
                  "feat_level": i,
                  "inputs_offsets": [
                      level_last_id(i),
                      level_last_id(i + 1),
                  ],
                  "weight_method": p.weight_method,
              }
          )
          node_ids[i].append(next(id_cnt))
      node_ids[max_level].append(node_ids[max_level][-1])
  
      for i in range(min_level + 1, max_level):
          # bottom-up path 2.
          p.nodes.append(
              {
                  "feat_level": i,
                  "inputs_offsets": level_all_ids(i)
                  + [level_last_id(i - 1)],
                  "weight_method": p.weight_method,
              }
          )
          node_ids[i].append(next(id_cnt))
  
      i = max_level
      p.nodes.append(
          {
              "feat_level": i,
              "inputs_offsets": [level_first_id(i)]
              + [level_last_id(i - 1)],
              "weight_method": p.weight_method,
          }
      )
      node_ids[i].append(next(id_cnt))
      node_ids[min_level].append(node_ids[min_level][-1])
  
      for i in range(min_level + 1, max_level + 1, 1):
          # bottom-up path 3.
          p.nodes.append(
              {
                  "feat_level": i,
                  "inputs_offsets": [
                      level_first_id(i),
                      level_last_id(i - 1)
                      if i != min_level + 1
                      else level_first_id(i - 1),
                  ],
                  "weight_method": p.weight_method,
              }
          )
          node_ids[i].append(next(id_cnt))
      node_ids[min_level].append(node_ids[min_level][-1])
  
      for i in range(max_level - 1, min_level, -1):
          # top-down path 4.
          p.nodes.append(
              {
                  "feat_level": i,
                  "inputs_offsets": [node_ids[i][0]]
                  + [node_ids[i][-1]]
                  + [level_last_id(i + 1)],
                  "weight_method": p.weight_method,
              }
          )
          node_ids[i].append(next(id_cnt))
      i = min_level
      p.nodes.append(
          {
              "feat_level": i,
              "inputs_offsets": [node_ids[i][0]]
              + [level_last_id(i + 1)],
              "weight_method": p.weight_method,
          }
      )
      node_ids[i].append(next(id_cnt))
      node_ids[max_level].append(node_ids[max_level][-1])
  
      for i in range(max_level, min_level - 1, -1):
          # quad-add path.
          p.nodes.append(
              {
                  "feat_level": i,
                  "inputs_offsets": [node_ids[i][2], node_ids[i][4]],
                  "weight_method": p.quad_method,
              }
          )
          node_ids[i].append(next(id_cnt))
  
      return p
  
imports: import itertools
  import hparams_config
label_desc: Use image node_id 2 for calling a global function with example usage: qufpn_config(min_level, max_level, weight_method) and returns: p