code: def revert_sync_batchnorm(
      module: torch.nn.Module,
      device: Optional[Union[str, torch.device]] = None,
  ) -> torch.nn.Module:
      """
      Helper function to convert all :class:`torch.nn.SyncBatchNorm` layers in the module to
      :attr:`BatchNorm*D` layers. This function reverts :meth:`torch.nn.SyncBatchNorm.convert_sync_batchnorm`.
  
      Args:
          module (nn.Module): module containing one or more :class:`torch.nn.SyncBatchNorm` layers
          device (optional): device in which the :attr:`BatchNorm*D` should be created,
                  default is cpu
  
      Returns:
          The original :attr:`module` with the converted :attr:`BatchNorm*D`
          layers. If the original :attr:`module` is a :class:`torch.nn.SyncBatchNorm` layer,
          a new :attr:`BatchNorm*D` layer object will be returned
          instead. Note that the :attr:`BatchNorm*D` layers returned will not have input dimension information.
  
      Example::
  
          >>> # Network with nn.BatchNorm layer
          >>> module = torch.nn.Sequential(
          >>>            torch.nn.Linear(20, 100),
          >>>            torch.nn.BatchNorm1d(100),
          >>>          ).cuda()
          >>> sync_bn_module = torch.nn.SyncBatchNorm.convert_sync_batchnorm(module)
          >>> reverted_module = revert_sync_batchnorm(sync_bn_module, torch.device("cuda"))
  
      """
      module_output = module
      if isinstance(module, torch.nn.modules.batchnorm.SyncBatchNorm):
          module_output = _BatchNormXd(
              module.num_features,
              module.eps,
              module.momentum,
              module.affine,
              module.track_running_stats,
              device,
          )
          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, revert_sync_batchnorm(child, device)
          )
      del module
      return module_output
  
imports: import os
  import tempfile
  from functools import wraps
  from typing import Any, Callable, cast, List, Optional, TypeVar, Union
  import torch
  import torch.distributed
  import torch.nn.functional
  from torch import Tensor
  from torch.distributed.elastic.utils.distributed import get_free_port
  from typing_extensions import Literal
label_desc: Use image node_id 14 for calling a global function with example usage: revert_sync_batchnorm(module, device) and returns: module_output