code: def enable_pytorch_sync_bn(module: torch.nn.Module) -> None:
      """Call _specify_ddp_gpu_num for all pytorch SyncBN layers so that it
      is happily running even without DDP. E.g. this is used by FSDP.
      """
      for layer in module.modules():
          if isinstance(
              layer, torch.nn.modules.SyncBatchNorm
          ) and hasattr(layer, "_specify_ddp_gpu_num"):
              # Number "1" below meant to be the number of GPUs for each DDP worker.
              # (i.e. "device_ids" in DDP. As far as I see, the value is not actually
              # used, but this call needs to be made to avoid an exception.
              # This function is removed from pytorch since 1.9.
              layer._specify_ddp_gpu_num(1)
  
file_path: fairscale/fairscale/internal/parallel.py
imports: from enum import Enum
  import sys
  from typing import TYPE_CHECKING, List, Optional, Sequence
  import torch
  import torch.distributed
  import torch.nn.functional
label_desc: Use image node_id 3 for calling a global function with example usage: enable_pytorch_sync_bn(module) without return types