code: def test_optimizer_backend_compatible(name):
      torch.set_grad_enabled(True)
      # model construction
      ch_model = ChModel()
      th_model = ThModel()
  
      # copy params
      th_model.a.weight.data = torch.from_numpy(
          numpy.copy(ch_model.a.W.data)
      )
      th_model.a.bias.data = torch.from_numpy(
          numpy.copy(ch_model.a.b.data)
      )
  
      # optimizer setup
      th_opt = dynamic_import_optimizer(name, "pytorch").build(
          th_model.parameters()
      )
      ch_opt = dynamic_import_optimizer(name, "chainer").build(ch_model)
  
      # forward
      ch_model.cleargrads()
      data = numpy.random.randn(2, 3).astype(numpy.float32)
      ch_loss = ch_model(data)
      th_loss = th_model(torch.from_numpy(data))
      chainer.functions.sum(ch_loss).backward()
      th_loss.backward()
      numpy.testing.assert_allclose(
          ch_loss.data, th_loss.item(), rtol=1e-6
      )
      ch_opt.update()
      th_opt.step()
      numpy.testing.assert_allclose(
          ch_model.a.W.data, th_model.a.weight.data.numpy(), rtol=1e-6
      )
      numpy.testing.assert_allclose(
          ch_model.a.b.data, th_model.a.bias.data.numpy(), rtol=1e-6
      )
  
file_path: espnet/test/test_optimizer.py
imports: import chainer
  import numpy
  import pytest
  import torch
  from espnet.optimizer.factory import dynamic_import_optimizer
  from espnet.optimizer.pytorch import OPTIMIZER_FACTORY_DICT
label_desc: Use image node_id 1 for calling a global function with example usage: test_optimizer_backend_compatible(name) without return types