code: def test_ensuring_substrate():
      prev_setting = pg.getConfigOption("useCupy")
      try:
          pg.setConfigOption("useCupy", True)
          ii = pg.ImageItem()
  
          data = cupy.random.randint(0, 255, size=(32, 32)).astype(
              cupy.uint8
          )
          assert data is ii._ensure_proper_substrate(data, cupy)
          assert isinstance(
              ii._ensure_proper_substrate(data, cupy), cupy.ndarray
          )
          assert data is not ii._ensure_proper_substrate(data, np)
          assert isinstance(
              ii._ensure_proper_substrate(data, np), np.ndarray
          )
  
          data = np.random.randint(0, 255, size=(32, 32)).astype(
              np.uint8
          )
          assert data is ii._ensure_proper_substrate(data, np)
          assert isinstance(
              ii._ensure_proper_substrate(data, np), np.ndarray
          )
          assert data is not ii._ensure_proper_substrate(data, cupy)
          assert isinstance(
              ii._ensure_proper_substrate(data, cupy), cupy.ndarray
          )
  
          data = range(0, 255)
          assert data is not ii._ensure_proper_substrate(data, np)
          assert isinstance(
              ii._ensure_proper_substrate(data, np), np.ndarray
          )
          assert data is not ii._ensure_proper_substrate(data, cupy)
          assert isinstance(
              ii._ensure_proper_substrate(data, cupy), cupy.ndarray
          )
      finally:
          pg.setConfigOption("useCupy", prev_setting)
  
file_path: pyqtgraph/tests/graphicsItems/test_ImageItem.py
imports: import time
  import numpy
  import pytest
  import pyqtgraph
  from pyqtgraph.Qt import QtCore, QtGui, QtTest
  from tests.image_testing import TransposedImageItem, assertImageApproved
label_desc: Use image node_id 2 for calling a global function with example usage: test_ensuring_substrate() without return types