code: def __init__(
      self,
      in_channels=(256, 512, 1024, 2048),
      out_channels=256,
      spatial_modulation_config=None,
      temporal_modulation_config=None,
      upsampling_config=None,
      downsampling_config=None,
      level_fusion_config=None,
      aux_head_config=None,
  ):
      super(TPN, self).__init__()
      assert isinstance(out_channels, int)
      self.in_channels = in_channels
      self.out_channels = out_channels
      self.num_ins = len(in_channels)
  
      self.temporal_modulation_ops = nn.ModuleList()
      self.upsampling_ops = nn.ModuleList()
      self.downsampling_ops = nn.ModuleList()
      self.level_fusion_op = LevelFusion(**level_fusion_config)
      self.spatial_modulation = SpatialModulation(
          **spatial_modulation_config
      )
      for i in range(0, self.num_ins, 1):
          inplanes = in_channels[-1]
          planes = out_channels
  
          if temporal_modulation_config is not None:
              # overwrite the temporal_modulation_config
              temporal_modulation_config["param"][
                  "downsample_scale"
              ] = temporal_modulation_config["scales"][i]
              temporal_modulation_config["param"]["inplanes"] = inplanes
              temporal_modulation_config["param"]["planes"] = planes
              temporal_modulation = TemporalModulation(
                  **temporal_modulation_config["param"]
              )
              self.temporal_modulation_ops.append(temporal_modulation)
  
          if i < self.num_ins - 1:
              if upsampling_config is not None:
                  # overwrite the upsampling_config
                  upsampling = Upsampling(**upsampling_config)
                  self.upsampling_ops.append(upsampling)
  
              if downsampling_config is not None:
                  # overwrite the downsampling_config
                  downsampling_config["param"]["inplanes"] = planes
                  downsampling_config["param"]["planes"] = planes
                  downsampling_config["param"][
                      "downsample_scale"
                  ] = downsampling_config["scales"]
                  downsampling = Downampling(
                      **downsampling_config["param"]
                  )
                  self.downsampling_ops.append(downsampling)
  
      out_dims = level_fusion_config["out_channels"]
  
      # Two pyramids
      self.level_fusion_op2 = LevelFusion(**level_fusion_config)
  
      self.pyramid_fusion_op = nn.Sequential(
          nn.Conv3d(out_dims * 2, 2048, 1, 1, 0, bias=False),
          nn.BatchNorm3d(2048),
          nn.ReLU(inplace=True),
      )
  
      # overwrite aux_head_config
      if aux_head_config is not None:
          aux_head_config["inplanes"] = self.in_channels[-2]
          self.aux_head = AuxHead(**aux_head_config)
      else:
          self.aux_head = None
  
imports: import numpy
  import torch
  import torch.nn
  import torch.utils.checkpoint
  import torch.nn.functional
label_desc: Use image node_id 1 to create a new TPN object from inherited base classes: nn with example: obj = TPN(in_channels, out_channels, spatial_modulation_config, temporal_modulation_config, upsampling_config, downsampling_config, level_fusion_config, aux_head_config)