code: def build_fpn(
      backbone,
      skip_connection_layers,
      pyramid_filters=256,
      segmentation_filters=128,
      classes=1,
      activation="sigmoid",
      use_batchnorm=True,
      aggregation="sum",
      dropout=None,
  ):
      input_ = backbone.input
      x = backbone.output
  
      # building decoder blocks with skip connections
      skips = [
          backbone.get_layer(name=i).output
          if isinstance(i, str)
          else backbone.get_layer(index=i).output
          for i in skip_connection_layers
      ]
  
      # build FPN pyramid
      p5 = FPNBlock(pyramid_filters, stage=5)(x, skips[0])
      p4 = FPNBlock(pyramid_filters, stage=4)(p5, skips[1])
      p3 = FPNBlock(pyramid_filters, stage=3)(p4, skips[2])
      p2 = FPNBlock(pyramid_filters, stage=2)(p3, skips[3])
  
      # add segmentation head to each
      s5 = DoubleConv3x3BnReLU(
          segmentation_filters, use_batchnorm, name="segm_stage5"
      )(p5)
      s4 = DoubleConv3x3BnReLU(
          segmentation_filters, use_batchnorm, name="segm_stage4"
      )(p4)
      s3 = DoubleConv3x3BnReLU(
          segmentation_filters, use_batchnorm, name="segm_stage3"
      )(p3)
      s2 = DoubleConv3x3BnReLU(
          segmentation_filters, use_batchnorm, name="segm_stage2"
      )(p2)
  
      # upsampling to same resolution
      s5 = layers.UpSampling2D(
          (8, 8), interpolation="nearest", name="upsampling_stage5"
      )(s5)
      s4 = layers.UpSampling2D(
          (4, 4), interpolation="nearest", name="upsampling_stage4"
      )(s4)
      s3 = layers.UpSampling2D(
          (2, 2), interpolation="nearest", name="upsampling_stage3"
      )(s3)
  
      # aggregating results
      if aggregation == "sum":
          x = layers.Add(name="aggregation_sum")([s2, s3, s4, s5])
      elif aggregation == "concat":
          concat_axis = (
              3 if backend.image_data_format() == "channels_last" else 1
          )
          x = layers.Concatenate(
              axis=concat_axis, name="aggregation_concat"
          )([s2, s3, s4, s5])
      else:
          raise ValueError(
              'Aggregation parameter should be in ("sum", "concat"), '
              "got {}".format(aggregation)
          )
  
      if dropout:
          x = layers.SpatialDropout2D(dropout, name="pyramid_dropout")(
              x
          )
  
      # final stage
      x = Conv3x3BnReLU(
          segmentation_filters, use_batchnorm, name="final_stage"
      )(x)
      x = layers.UpSampling2D(
          size=(2, 2), interpolation="bilinear", name="final_upsampling"
      )(x)
  
      # model head (define number of output classes)
      x = layers.Conv2D(
          filters=classes,
          kernel_size=(3, 3),
          padding="same",
          use_bias=True,
          kernel_initializer="glorot_uniform",
          name="head_conv",
      )(x)
      x = layers.Activation(activation, name=activation)(x)
  
      # create keras model instance
      model = models.Model(input_, x)
  
      return model
  
file_path: segmentation_models/segmentation_models/models/fpn.py
imports: from keras_applications import get_submodules_from_kwargs
  from ._common_blocks import Conv2dBn
  from ._utils import freeze_model, filter_keras_submodules
  from ..backbones.backbones_factory import Backbones
label_desc: Use image node_id 5 for calling a global function with example usage: build_fpn(backbone, skip_connection_layers, pyramid_filters, segmentation_filters, classes, activation, use_batchnorm, aggregation, dropout) and returns: model