docstr: Check interprocess parameter sharing works if models share links
docstr_tok: ["Check","interprocess","parameter","sharing","works","if","models","share","links"]
code: def test_shared_link(self):
      """Check interprocess parameter sharing works if models share links"""
  
      head = L.Linear(2, 2)
      model_a = chainer.ChainList(head.copy(), L.Linear(2, 3))
      model_b = chainer.ChainList(head.copy(), L.Linear(2, 4))
  
      a_arrays = async_.extract_params_as_shared_arrays(model_a)
      b_arrays = async_.extract_params_as_shared_arrays(model_b)
  
      print(("model_a shared_arrays", a_arrays))
      print(("model_b shared_arrays", b_arrays))
  
      head = L.Linear(2, 2)
      model_a = chainer.ChainList(head.copy(), L.Linear(2, 3))
      model_b = chainer.ChainList(head.copy(), L.Linear(2, 4))
  
      async_.set_shared_params(model_a, a_arrays)
      async_.set_shared_params(model_b, b_arrays)
  
      print("model_a replaced")
      a_params = dict(model_a.namedparams())
      for param_name, param in list(a_params.items()):
          print((param_name, param.array.ctypes.data))
  
      print("model_b replaced")
      b_params = dict(model_b.namedparams())
      for param_name, param in list(b_params.items()):
          print((param_name, param.array.ctypes.data))
  
      # Pointers to head parameters must be the same
      self.assertEqual(
          a_params["/0/W"].array.ctypes.data,
          b_params["/0/W"].array.ctypes.data,
      )
      self.assertEqual(
          a_params["/0/b"].array.ctypes.data,
          b_params["/0/b"].array.ctypes.data,
      )
  
      # Pointers to tail parameters must be different
      self.assertNotEqual(
          a_params["/1/W"].array.ctypes.data,
          b_params["/1/W"].array.ctypes.data,
      )
      self.assertNotEqual(
          a_params["/1/b"].array.ctypes.data,
          b_params["/1/b"].array.ctypes.data,
      )
  
imports: import multiprocessing
  import os
  import signal
  import sys
  import unittest
  import warnings
  import chainer
  import chainer.links
  from chainer import optimizers
  import copy
  import numpy
  import chainerrl
  from chainerrl.misc import async_
label_desc: Use image node_id 6 for calling the TestAsync obj's underlying member method code with example usage: obj.test_shared_link() without return types