def __init__(self,
                 in_channels,
                 out_channels,
                 spatial_scales,
                 num_levels=4,
                 use_bias=False):
        """
        Args:
            in_channels (list[int]): input channels of each level which can be 
                derived from the output shape of backbone by from_config
            out_channel (int): output channel of each level.
            spatial_scales (list[float]): list of scaling factors to upsample or downsample
                the input features for creating pyramid features which can be derived from 
                the output shape of backbone by from_config
            num_levels (int): number of levels of output features.
            use_bias (bool): whether use bias or not.
        """
        super(SimpleFeaturePyramid, self).__init__()

        self.in_channels = in_channels[0]
        self.out_channels = out_channels
        self.num_levels = num_levels

        self.stages = []
        dim = self.in_channels
        if num_levels == 4:
            scale_factors = [2.0, 1.0, 0.5]
        elif num_levels == 5:
            scale_factors = [4.0, 2.0, 1.0, 0.5]
        else:
            raise NotImplementedError(
                f"num_levels={num_levels} is not supported yet.")

        dim = in_channels[0]
        for idx, scale in enumerate(scale_factors):
            out_dim = dim
            if scale == 4.0:
                layers = [
                    nn.Conv2DTranspose(
                        dim, dim // 2, kernel_size=2, stride=2),
                    nn.LayerNorm(dim // 2),
                    nn.GELU(),
                    nn.Conv2DTranspose(
                        dim // 2, dim // 4, kernel_size=2, stride=2),
                ]
                out_dim = dim // 4
            elif scale == 2.0:
                layers = [
                    nn.Conv2DTranspose(
                        dim, dim // 2, kernel_size=2, stride=2)
                ]
                out_dim = dim // 2
            elif scale == 1.0:
                layers = []
            elif scale == 0.5:
                layers = [nn.MaxPool2D(kernel_size=2, stride=2)]

            layers.extend([
                nn.Conv2D(
                    out_dim,
                    out_channels,
                    kernel_size=1,
                    bias_attr=use_bias, ), LayerNorm(out_channels), nn.Conv2D(
                        out_channels,
                        out_channels,
                        kernel_size=3,
                        padding=1,
                        bias_attr=use_bias, ), LayerNorm(out_channels)
            ])
            layers = nn.Sequential(*layers)

            stage = -int(math.log2(spatial_scales[0] * scale_factors[idx]))
            self.add_sublayer(f"simfp_{stage}", layers)
            self.stages.append(layers)

        # top block output feature maps.
        self.top_block = nn.Sequential(
            nn.MaxPool2D(
                kernel_size=1, stride=2, padding=0))

        Args:
            in_channels (list[int]): input channels of each level which can be 
                derived from the output shape of backbone by from_config
            out_channel (int): output channel of each level.
            spatial_scales (list[float]): list of scaling factors to upsample or downsample
                the input features for creating pyramid features which can be derived from 
                the output shape of backbone by from_config
            num_levels (int): number of levels of output features.
            use_bias (bool): whether use bias or not.
        
ppdet/modeling/backbones/vit_mae.py