code: def get_state(chain):
      assert isinstance(chain, (chainer.Chain, chainer.ChainList))
      state = []
      for link in chain.children():
          if isinstance(link, chainer.links.LSTM):
              state.append((link.c, link.h))
          elif isinstance(link, Recurrent):
              state.append(link.get_state())
          elif isinstance(link, (chainer.Chain, chainer.ChainList)):
              state.append(get_state(link))
          else:
              state.append(None)
      return state
  
imports: from abc import ABCMeta
  from abc import abstractmethod
  import collections
  import contextlib
  import chainer
label_desc: Use image node_id 2 for calling a global function with example usage: get_state(chain) and returns: state