code: def test_global_hook(self):
      model, x, dot = self._create_model_and_data()
      hook = MyLinkHook()
  
      with hook:
          model(chainer.Variable(x), "foo", test2="bar")
  
      # added
      assert len(hook.added_args) == 1
      assert hook.added_args[0][1] is None
  
      # deleted
      assert len(hook.added_args) == 1
      assert hook.deleted_args[0][1] is None
  
      # forward_preprocess
      assert len(hook.forward_preprocess_args) == 2
      # - MyModel
      args = hook.forward_preprocess_args[0][1]
      assert args.link is model
      assert args.forward_name == "forward"
      assert len(args.args) == 2
      numpy.testing.assert_array_equal(args.args[0].data, x)
      assert args.args[1] == "foo"
      assert len(args.kwargs) == 1
      assert args.kwargs["test2"] == "bar"
      # - Linear
      args = hook.forward_preprocess_args[1][1]
      assert args.link is model.l1
      assert args.forward_name == "forward"
  
      # forward_postprocess
      assert len(hook.forward_postprocess_args) == 2
      # - Linear
      args = hook.forward_postprocess_args[0][1]
      assert args.link is model.l1
      assert args.forward_name == "forward"
      # - MyModel
      args = hook.forward_postprocess_args[1][1]
      assert args.link is model
      assert args.forward_name == "forward"
      assert len(args.args) == 2
      numpy.testing.assert_array_equal(args.args[0].data, x)
      assert args.args[1] == "foo"
      assert len(args.kwargs) == 1
      assert args.kwargs["test2"] == "bar"
      numpy.testing.assert_array_equal(args.out.data, dot)
  
      # Test callback call order
      time_sequence = [
          hook.added_args[0][0],
          hook.forward_preprocess_args[0][0],
          hook.forward_preprocess_args[1][0],
          hook.forward_postprocess_args[0][0],
          hook.forward_postprocess_args[1][0],
          hook.deleted_args[0][0],
      ]
      assert sorted(time_sequence) == time_sequence
  
imports: import time
  import unittest
  import numpy
  import chainer
  from chainer import testing
label_desc: Use image node_id 3 for calling the TestLinkHook obj's underlying member method code with example usage: obj.test_global_hook() without return types