code: def memory_allocated():
      rank = dist.get_rank()
      torch.cuda.set_device(rank)
  
      x = torch.randn(50, 2048, 7, 7).to(rank)
      torch_bn = torch.nn.SyncBatchNorm(2048).cuda()
      torch_bn = DDP(torch_bn, device_ids=[rank])
      fs_bn = SyncBatchNorm(2048).cuda()
      fs_bn = DDP(fs_bn, device_ids=[rank])
      torch_x = x.detach()
      torch_x.requires_grad = True
      fs_x = x.detach()
      fs_x.requires_grad = True
      torch.cuda.empty_cache()
      mem_at_start = torch.cuda.memory_stats()[
          "allocated_bytes.all.current"
      ]
      torch_y = torch_bn(torch_x)
      torch.cuda.empty_cache()
      mem_after_torch = torch.cuda.memory_stats()[
          "allocated_bytes.all.current"
      ]
      fs_y = fs_bn(fs_x)
      torch.cuda.empty_cache()
      mem_final = torch.cuda.memory_stats()[
          "allocated_bytes.all.current"
      ]
      torch_used = mem_after_torch - mem_at_start
      fs_used = mem_final - mem_after_torch
      assert fs_used < (
          torch_used * 1.01
      ), f"{fs_used} < {torch_used * 1.01}"
  
imports: import functools
  import tempfile
  import pytest
  import torch
  import torch.distributed
  import torch.multiprocessing
  import torch.nn
  from torch.nn.parallel import DistributedDataParallel
  from fairscale.experimental.nn import SyncBatchNorm
  from fairscale.nn.checkpoint import checkpoint_wrapper
label_desc: Use image node_id 15 for calling a global function with example usage: memory_allocated() without return types