code: def transfer_lm(ch_rnnlm, th_rnnlm):
      assert isinstance(ch_rnnlm, lm_chainer.RNNLM)
      assert isinstance(th_rnnlm, lm_pytorch.RNNLM)
      th_rnnlm.embed.weight.data = torch.from_numpy(
          ch_rnnlm.embed.W.data
      )
      if th_rnnlm.typ == "lstm":
          for n in range(ch_rnnlm.n_layers):
              transfer_lstm(ch_rnnlm.rnn[n], th_rnnlm.rnn[n])
      else:
          assert False
      th_rnnlm.lo.weight.data = torch.from_numpy(ch_rnnlm.lo.W.data)
      th_rnnlm.lo.bias.data = torch.from_numpy(ch_rnnlm.lo.b.data)
  
file_path: espnet/test/test_lm.py
imports: from test.test_beam_search import prepare, rnn_args
  import chainer
  import numpy
  import pytest
  import torch
  import espnet.lm.chainer_backend.lm
  import espnet.nets.pytorch_backend.lm.default
  from espnet.nets.beam_search import beam_search
  from espnet.nets.lm_interface import dynamic_import_lm
  from espnet.nets.scorers.length_bonus import LengthBonus
label_desc: Use image node_id 2 for calling a global function with example usage: transfer_lm(ch_rnnlm, th_rnnlm) without return types