code: def convert_sync_batchnorm(module, process_group=None):
      # convert both BatchNorm and BatchNormAct layers to Synchronized variants
      module_output = module
      if isinstance(module, torch.nn.modules.batchnorm._BatchNorm):
          if isinstance(module, BatchNormAct2d):
              # convert timm norm + act layer
              module_output = SyncBatchNormAct(
                  module.num_features,
                  module.eps,
                  module.momentum,
                  module.affine,
                  module.track_running_stats,
                  process_group=process_group,
              )
              # set act and drop attr from the original module
              module_output.act = module.act
              module_output.drop = module.drop
          else:
              # convert standard BatchNorm layers
              module_output = torch.nn.SyncBatchNorm(
                  module.num_features,
                  module.eps,
                  module.momentum,
                  module.affine,
                  module.track_running_stats,
                  process_group,
              )
          if module.affine:
              with torch.no_grad():
                  module_output.weight = module.weight
                  module_output.bias = module.bias
          module_output.running_mean = module.running_mean
          module_output.running_var = module.running_var
          module_output.num_batches_tracked = module.num_batches_tracked
          if hasattr(module, "qconfig"):
              module_output.qconfig = module.qconfig
      for name, child in module.named_children():
          module_output.add_module(
              name, convert_sync_batchnorm(child, process_group)
          )
      del module
      return module_output
  
imports: from typing import Union, List, Optional, Any
  import torch
  from torch import nn
  from torch.nn import functional
  from torchvision.ops.misc import FrozenBatchNorm2d
  from .create_act import get_act_layer
  from .fast_norm import is_fast_norm, fast_group_norm, fast_layer_norm
  from .trace_utils import _assert
label_desc: Use image node_id 2 for calling a global function with example usage: convert_sync_batchnorm(module, process_group) and returns: module_output