code: def test_array_grad_invalid_grad(
      invalid_shape, invalid_dtype, invalid_device
  ):
      shape = (3, 1)
      dtype = chainerx.float64
      device = "native:0"
  
      array = chainerx.ones(shape, dtype, device=device)
      array.require_grad()
  
      grad_shape = shape if invalid_shape is None else invalid_shape
      grad_dtype = dtype if invalid_dtype is None else invalid_dtype
      grad_device = device if invalid_device is None else invalid_device
      invalid_grad = chainerx.ones(
          grad_shape, grad_dtype, device=grad_device
      )
  
      with pytest.raises(chainerx.GradientError):
          array.set_grad(invalid_grad)
      with pytest.raises(chainerx.GradientError):
          array.grad = invalid_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 27 for calling a global function with example usage: test_array_grad_invalid_grad(invalid_shape, invalid_dtype, invalid_device) without return types