code: def set_state(chain, state):
      assert isinstance(chain, (chainer.Chain, chainer.ChainList))
      for link, s in zip(chain.children(), state):
          if isinstance(link, chainer.links.LSTM):
              c, h = s
              # LSTM.set_state doesn't accept None state
              if c is not None:
                  link.set_state(c, h)
          elif isinstance(link, Recurrent):
              link.set_state(s)
          elif isinstance(link, (chainer.Chain, chainer.ChainList)):
              set_state(link, s)
          else:
              assert s is None
  
imports: from abc import ABCMeta
  from abc import abstractmethod
  import collections
  import contextlib
  import chainer
label_desc: Use image node_id 4 for calling a global function with example usage: set_state(chain, state) without return types