docstr: Tests, whether compression and decompression work properly.
docstr_tok: ["Tests",",","whether","compression","and","decompression","work","properly","."]
code: def test_compression(self):
      """Tests, whether compression and decompression work properly."""
      s1 = SampleBatch(
          {
              "a": np.array([1, 2, 3, 2, 3, 4]),
              "b": {"c": np.array([4, 5, 6, 5, 6, 7])},
          }
      )
      # Test, whether compressing happens in-place.
      s1.compress(columns={"a", "b"}, bulk=True)
      self.assertTrue(is_compressed(s1["a"]))
      self.assertTrue(is_compressed(s1["b"]["c"]))
      self.assertTrue(isinstance(s1["b"], dict))
  
      # Test, whether de-compressing happens in-place.
      s1.decompress_if_needed(columns={"a", "b"})
      check(s1["a"], [1, 2, 3, 2, 3, 4])
      check(s1["b"]["c"], [4, 5, 6, 5, 6, 7])
      it = s1.rows()
      next(it)
      check(next(it), {"a": 2, "b": {"c": 5}})
  
imports: import copy
  import functools
  import os
  import unittest
  import numpy
  import torch
  import tree
  import ray
  from ray.rllib.models.repeated_values import RepeatedValues
  from ray.rllib.policy.sample_batch import SampleBatch, attempt_count_timesteps, concat_samples
  from ray.rllib.utils.compression import is_compressed
  from ray.rllib.utils.framework import try_import_torch
  from ray.rllib.utils.test_utils import check
  from ray.rllib.utils.torch_utils import convert_to_torch_tensor
label_desc: Use image node_id 9 for calling the TestSampleBatch obj's underlying member method code with example usage: obj.test_compression() without return types