code: def _set_persistent_values_recursively(
      link, persistent_name, shared_array
  ):
      if persistent_name.startswith("/"):
          persistent_name = persistent_name[1:]
      if hasattr(link, persistent_name):
          attr_name = persistent_name
          attr = getattr(link, attr_name)
          if isinstance(attr, np.ndarray):
              setattr(
                  link,
                  persistent_name,
                  np.frombuffer(shared_array, dtype=attr.dtype).reshape(
                      attr.shape
                  ),
              )
          else:
              assert np.isscalar(attr)
              # We wrap scalars with np.ndarray because
              # multiprocessing.RawValue cannot be used as a scalar, while
              # np.ndarray can be.
              typecode = np.asarray(attr).dtype.char
              setattr(
                  link,
                  attr_name,
                  np.frombuffer(shared_array, dtype=typecode).reshape(
                      ()
                  ),
              )
      else:
          assert isinstance(link, (chainer.Chain, chainer.ChainList))
          assert "/" in persistent_name
          child_name, remaining = persistent_name.split("/", 1)
          if isinstance(link, chainer.Chain):
              _set_persistent_values_recursively(
                  getattr(link, child_name), remaining, shared_array
              )
          else:
              _set_persistent_values_recursively(
                  link[int(child_name)], remaining, shared_array
              )
  
imports: import multiprocessing
  import warnings
  import chainer
  import numpy
  import chainerrl
  from chainerrl.misc import random_seed
label_desc: Use image node_id 2 for calling a global function with example usage: _set_persistent_values_recursively(link, persistent_name, shared_array) without return types