code: def test_flatten():
      r = np.random.randn
      x = (1.0, r(2, 3), [r(1, 4), {"x": 2.0, "y": r(4, 2)}])
      x_flat, unflatten = flatten(x)
      assert x_flat.shape == (20,)
      assert x_flat[0] == 1.0
      assert np.all(x_flat == flatten(unflatten(x_flat))[0])
  
      y = (1.0, 2.0, [3.0, {"x": 2.0, "y": 4.0}])
      y_flat, unflatten = flatten(y)
      assert y_flat.shape == (5,)
      assert y == unflatten(y_flat)
  
file_path: autograd/tests/test_misc.py
imports: import autograd.numpy
  import autograd.numpy.random
  from autograd.test_util import scalar_close
  from autograd import make_vjp, grad
  from autograd.tracer import primitive
  from autograd.misc import const_graph, flatten
label_desc: Use image node_id 3 for calling a global function with example usage: test_flatten() without return types