code: def test_interceptors(self):
      # Tests whether interceptors work as intended
  
      some_array = np.array([1, 2, 3])
      batch = SampleBatch({SampleBatch.OBS: some_array})
  
      device = torch.device("cpu")
  
      self.assertTrue(batch[SampleBatch.OBS] is some_array)
  
      batch.set_get_interceptor(
          functools.partial(convert_to_torch_tensor, device=device)
      )
  
      self.assertTrue(
          all(
              convert_to_torch_tensor(some_array)
              == batch[SampleBatch.OBS]
          )
      )
  
      # This test requires a GPU, otherwise we can't test whether we are
      # moving between devices
      if not torch.cuda.is_available():
          raise ValueError(
              "This test can only fail if cuda is available."
          )
  
      another_array = np.array([4, 5, 6])
      another_batch = SampleBatch({SampleBatch.OBS: another_array})
  
      another_device = torch.device("cuda")
  
      self.assertTrue(another_batch[SampleBatch.OBS] is another_array)
      another_batch.set_get_interceptor(
          functools.partial(
              convert_to_torch_tensor, device=another_device
          )
      )
      check(another_batch[SampleBatch.OBS], another_array)
      self.assertFalse(another_batch[SampleBatch.OBS] is another_array)
  
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 16 for calling the TestSampleBatch obj's underlying member method code with example usage: obj.test_interceptors() without return types