code: def test_nonblocking():
      """Tests cpu runs ahead of the GPU in the measuring process."""
      big = torch.rand(10, 1000, 1000).cuda()
      ecp = ECP(dim=2, top_k_percents=[1, 5, 10, 50, 90])
      start = time.time()
      out = ecp.measure(big)
      out_fft = ecp.measure_fft(big)
      cpu_time = time.time() - start
      torch.cuda.synchronize()
      gpu_time = time.time() - start
      assert (
          cpu_time * 5 < gpu_time
      ), f"GPU time should dominate {cpu_time} vs. {gpu_time}"
      for o in [out, out_fft]:
          # validate the output
          p = [x.item() for x in o]
          for n, n1 in zip(p, p[1:]):
              assert n <= n1 and n >= 0 and n <= 100, f"n={n} n1={n1}"
  
file_path: fairscale/tests/experimental/wgit/test_signal_sparsity_profiling.py
imports: import time
  import pytest
  import torch
  from fairscale.experimental.wgit.signal_sparsity_profiling import EnergyConcentrationProfile
  from fairscale.fair_dev.testing.testing import objects_are_equal, skip_if_no_cuda
label_desc: Use image node_id 1 for calling a global function with example usage: test_nonblocking() without return types