code: def apply_sequential(inputs, modules):
      for mod in modules:
          if isinstance(mod, (nn.BatchNorm2d, nn.SyncBatchNorm)):
              # for BN layer, normalize all inputs together
              shapes = [i.shape for i in inputs]
              spatial_sizes = [s[2] * s[3] for s in shapes]
              x = [i.flatten(2) for i in inputs]
              x = torch.cat(x, dim=2).unsqueeze(3)
              x = mod(x).split(spatial_sizes, dim=2)
              inputs = [i.view(s) for s, i in zip(shapes, x)]
          else:
              inputs = [mod(i) for i in inputs]
      return inputs
  
file_path: detectron2/projects/Rethinking-BatchNorm/configs/retinanet_SyncBNhead_SharedTraining.py
imports: from typing import List
  import torch
  from torch import Tensor, nn
  from detectron2.modeling.meta_arch.retinanet import RetinaNetHead
  from .retinanet_SyncBNhead import model, dataloader, lr_multiplier, optimizer, train
label_desc: Use image node_id 1 for calling a global function with example usage: apply_sequential(inputs, modules) and returns: inputs