code: def test_grad_with_retain_grad():
      shape = (1,)
      backprop_id = None
      dtype = chainerx.float32
  
      xs = (
          chainerx.full(shape, 3, dtype).require_grad(),
          chainerx.full(shape, 5, dtype).require_grad(),
      )
  
      expected_gxs = (chainerx.full(shape, 4, dtype),)
  
      # This test can't use _check_grad
      # because when using a forward function
      # it is not possible to easily expose the intermediate
      # values of the graph to verify the gradients
      a = xs[0] * 2
      b = a + xs[1]
      c = a + b
      expected_retain = (
          chainerx.full(shape, 1, dtype),
          chainerx.full(shape, 2, dtype),
      )
      gxs = chainerx.grad([c], xs, backprop_id, retain_grad=True)
  
      # Check gradients.
      for gx, expected_gx in zip(gxs, expected_gxs):
          _assert_arrays_equal(gx, expected_gx)
  
      _assert_arrays_equal(expected_retain[0], b.get_grad(backprop_id))
      _assert_arrays_equal(expected_retain[1], a.get_grad(backprop_id))
  
imports: import chainerx
  import pytest
label_desc: Use image node_id 28 for calling a global function with example usage: test_grad_with_retain_grad() without return types