class_docstr: Instance Context Encoder
  1. construct feature pyramids from ResNet
  2. enlarge receptive fields (ppm)
  3. multi-scale fusion
class_docstr_tok: ["Instance","Context","Encoder","1.","construct","feature","pyramids","from","ResNet","2.","enlarge","receptive","fields","(","ppm",")","3.","multi-scale","fusion"]
code: def forward(self, features):
      features = features[::-1]
      prev_features = self.fpn_laterals[0](features[0])
      if self.with_ppm:
          prev_features = self.ppm(prev_features)
      outputs = [self.fpn_outputs[0](prev_features)]
      for feature, lat_conv, output_conv in zip(
          features[1:], self.fpn_laterals[1:], self.fpn_outputs[1:]
      ):
          lat_features = lat_conv(feature)
          top_down_features = F.interpolate(
              prev_features, scale_factor=2.0, mode="nearest"
          )
          prev_features = lat_features + top_down_features
          outputs.insert(0, output_conv(prev_features))
      size = outputs[0].shape[2:]
      features = [outputs[0]] + [
          F.interpolate(x, size, mode="bilinear", align_corners=False)
          for x in outputs[1:]
      ]
      features = self.fusion(torch.cat(features, dim=1))
      return features
  
file_path: mmdetection/projects/SparseInst/sparseinst/encoder.py
imports: import torch
  import torch.nn
  import torch.nn.functional
  from mmengine.model.weight_init import caffe2_xavier_init, kaiming_init
  from mmdet.registry import MODELS
label_desc: Use image node_id 2 for calling the InstanceContextEncoder obj's underlying member method code with example usage: obj.forward(features) and returns: features