code: def test_lossy_compress(
      tensor, expd_sst, expd_dst, expd_rt, dim, unused, k, device
  ):
      """Tests the lossy_compress method against expected sst, dst and reconstruced tensor."""
      if device == "cuda" and not torch.cuda.is_available():
          pytest.skip("no GPU")
  
      sparser = SignalSparsity(
          sst_top_k_element=k,
          sst_top_k_dim=dim,
          dst_top_k_element=k,
          dst_top_k_dim=dim,
      )
      lossy_dense, sst, dst = sparser.lossy_compress(tensor.to(device))
      objects_are_equal(
          sst.to(device),
          expd_sst.to(device),
          raise_exception=True,
          rtol=RTOL,
          atol=ATOL,
      )
      objects_are_equal(
          dst.to(device),
          expd_dst.to(device),
          raise_exception=True,
          rtol=RTOL,
          atol=ATOL,
      )
      objects_are_equal(
          lossy_dense.to(device),
          expd_rt.to(device),
          raise_exception=True,
          rtol=RTOL,
          atol=ATOL,
      )
  
file_path: fairscale/tests/experimental/wgit/test_signal_sparsity.py
imports: import pytest
  import torch
  from fairscale.experimental.wgit.signal_sparsity import SignalSparsity, random_sparse_mask
  from fairscale.fair_dev.testing.testing import objects_are_equal
label_desc: Use image node_id 10 for calling a global function with example usage: test_lossy_compress(tensor, expd_sst, expd_dst, expd_rt, dim, unused, k, device) without return types