code: def _map_links(func, link):
      if isinstance(link, chainer.Chain):
          children_names = link._children.copy()
          for name in children_names:
              child = getattr(link, name)
              new_child = func(child)
              if new_child is child:
                  _map_links(func, child)
              else:
                  delattr(link, name)
                  with link.init_scope():
                      setattr(link, name, new_child)
      elif isinstance(link, chainer.ChainList):
          children = link._children
          for i in range(len(children)):
              child = children[i]
              new_child = func(child)
              if new_child is child:
                  _map_links(func, child)
              else:
                  # mimic ChainList.add_link
                  children[i] = new_child
                  children[i].name = str(i)
  
                  if isinstance(link, Sequence):
                      _replace_unique_item(
                          link.layers, child, new_child
                      )
                  # Check chainer.Sequential if it exists.
                  sequential_class = getattr(chainer, "Sequential", ())
                  if isinstance(link, sequential_class):
                      _replace_unique_item(
                          link._layers, child, new_child
                      )
  
imports: import chainer
  from chainer.links import Linear
  from chainerrl.links.noisy_linear import FactorizedNoisyLinear
  from chainerrl.links.sequence import Sequence
label_desc: Use image node_id 2 for calling a global function with example usage: _map_links(func, link) without return types