code: def stateful_links(chain):
      for link in chain.children():
          if isinstance(link, (chainer.links.LSTM, Recurrent)):
              yield link
          elif isinstance(link, (chainer.Chain, chainer.ChainList)):
              for m in stateful_links(link):
                  yield m
  
imports: from abc import ABCMeta
  from abc import abstractmethod
  import collections
  import contextlib
  import chainer
label_desc: Use image node_id 3 for calling a global function with example usage: stateful_links(chain) without return types