code: def test_gifti_image():
      # Check that we're not modifying the default empty list in the default
      # arguments.
      gi = GiftiImage()
      assert gi.darrays == []
      assert gi.meta == {}
      assert gi.labeltable.labels == []
      arr = np.zeros((2, 3))
      gi.darrays.append(arr)
      # Now check we didn't overwrite the default arg
      gi = GiftiImage()
      assert gi.darrays == []
  
      # Test darrays / numDA
      gi = GiftiImage()
      assert gi.numDA == 0
  
      # Test from numpy numeric array
      data = rng.random(5, dtype=np.float32)
      da = GiftiDataArray(data)
      gi.add_gifti_data_array(da)
      assert gi.numDA == 1
      assert_array_equal(gi.darrays[0].data, data)
  
      # Test removing
      gi.remove_gifti_data_array(0)
      assert gi.numDA == 0
  
      # Remove from empty
      gi = GiftiImage()
      gi.remove_gifti_data_array_by_intent(0)
      assert gi.numDA == 0
  
      # Remove one
      gi = GiftiImage()
      da = GiftiDataArray(np.zeros((5,), np.float32), intent=0)
      gi.add_gifti_data_array(da)
  
      gi.remove_gifti_data_array_by_intent(3)
      assert gi.numDA == 1, "data array should exist on 'missed' remove"
  
      gi.remove_gifti_data_array_by_intent(da.intent)
      assert gi.numDA == 0
  
imports: import itertools
  import sys
  import warnings
  from io import BytesIO
  import numpy
  import pytest
  from numpy.testing import assert_array_almost_equal, assert_array_equal
  from nibabel.tmpdirs import InTemporaryDirectory
  from ...None import load
  from ...fileholders import FileHolder
  from ...nifti1 import data_type_codes
  from ...testing import get_test_data
  from ..None import GiftiCoordSystem, GiftiDataArray, GiftiImage, GiftiLabel, GiftiLabelTable, GiftiMetaData, GiftiNVPairs
  from .test_parse_gifti_fast import DATA_FILE1, DATA_FILE2, DATA_FILE3, DATA_FILE4, DATA_FILE5, DATA_FILE6
label_desc: Use image node_id 2 for calling a global function with example usage: test_gifti_image() without return types