code: def test_corr_mean():
      """
      Test _compute_intra_grad_corr_mean and _gather_flat_grad using ddp.no_sync()
      We also demonstrate how cosine similarity between consecutive gradients can be computed using _gather_flat_grad
      """
      world_size = 2
      temp_file_name = tempfile.mkstemp()[1]
  
      from fairscale.fair_dev.testing.golden_testing_data import (
          corr_mean_test_data,
      )
  
      test_case = corr_mean_test_data[0]
  
      mp.spawn(
          _test_corr_mean_func,
          args=(world_size, temp_file_name, test_case),
          nprocs=world_size,
          join=True,
      )
  
imports: import tempfile
  import numpy
  import pytest
  import torch
  from torch import Tensor
  import torch.distributed
  import torch.multiprocessing
  from torch.nn import Linear
  from torch.nn.parallel import DistributedDataParallel
  from torch.optim import SGD
  from fairscale.fair_dev.testing.golden_testing_data import adascale_test_data
  from fairscale.fair_dev.testing.testing import skip_if_single_gpu
  from fairscale.internal import torch_version
  from fairscale.nn.data_parallel import FullyShardedDataParallel
  from fairscale.nn.data_parallel import ShardedDataParallel
  from fairscale.optim import OSS, AdaScale
label_desc: Use image node_id 8 for calling a global function with example usage: test_corr_mean() without return types