code: def test_array_cleargrad():
      dtype = chainerx.float32
      array = chainerx.array([2, 5, 1], dtype)
      grad = chainerx.array([5, 7, 8], dtype)
  
      # Set grad, get it and save it
      array.require_grad().set_grad(grad)
      del grad
      saved_grad = array.get_grad()
  
      # Clear grad
      array.cleargrad()
      assert array.get_grad() is None
  
      assert saved_grad._debug_flat_data == [
          5,
          7,
          8,
      ], "Clearing grad must not affect previously retrieved grad"
  
imports: import copy
  import math
  import pickle
  import numpy
  import pytest
  import chainerx
  import chainerx.testing
  from chainerx_tests import array_utils
label_desc: Use image node_id 24 for calling a global function with example usage: test_array_cleargrad() without return types