code: def test_image_nan_rgb(texture_format, num_bands):
      size = (40, 40)
      data = np.ones((40, 40, num_bands))
      data[:5, :5, :3] = np.nan  # upper left - RGB all NaN
      data[:5, 20:25, 0] = np.nan  # upper middle - R NaN
      data[:5, -5:, :3] = 0  # upper right - opaque RGB black square
      data[-5:, -5:, :] = np.nan  # lower right RGBA all NaN
      if num_bands == 4:
          data[-5:, :5, 3] = np.nan  # lower left - Alpha NaN
  
      expected = (np.ones((40, 40, 4)) * 255).astype(np.uint8)
      # upper left - NaN goes to opaque black
      expected[:5, :5, :3] = 0
      # upper middle -> NaN R goes to 0
      expected[:5, 20:25, 0] = 0
      # upper right - opaque RGB black square
      expected[:5, -5:, :3] = 0
      # lower right - NaN RGB/A goes to 0
      # RGBA case - we see the green background behind the image
      expected[-5:, -5:, 0] = 0
      expected[-5:, -5:, 2] = 0
      if num_bands == 3:
          # RGB case - opaque black because Alpha defaults 1
          expected[-5:, -5:, 1] = 0
      # lower left - NaN Alpha goes to 0
      if num_bands == 4:
          # see the green background behind the image
          expected[-5:, :5, 0] = 0
          expected[-5:, :5, 2] = 0
  
      with TestingCanvas(size=size[::-1], bgcolor=(0, 1, 0)) as c:
          Image(
              data,
              cmap="grays",
              texture_format=texture_format,
              parent=c.scene,
          )
          rendered = c.render()
          np.testing.assert_allclose(rendered, expected)
  
file_path: vispy/vispy/visuals/tests/test_image.py
imports: from unittest import mock
  from vispy.scene import Image, PanZoomCamera
  from vispy.testing import requires_application, TestingCanvas, run_tests_if_main, IS_CI
  from vispy.testing.image_tester import assert_image_approved, downsample
  import numpy
  import pytest
  from vispy.testing.rendered_array_tester import compare_render, max_for_dtype
label_desc: Use image node_id 8 for calling a global function with example usage: test_image_nan_rgb(texture_format, num_bands) without return types