code: def check_communication(gpu, param):
      with chainer.using_config("dtype", param.dtype):
          communicator = create_communicator(gpu, param)
          rank_send = (communicator.rank + 1) % communicator.size
          rank_recv = (communicator.rank - 1) % communicator.size
          x = create_x(gpu, param, communicator)
          (model, entire_model) = create_models(
              gpu, param, communicator
          )
  
          if communicator.rank == 0:
              # Input process.
              y = function(model(x))
              err = chainermn.functions.send(y, communicator, rank_send)
              err.backward()
              grad = model.W.grad
  
              # Compute the expected gradient.
              x_ = x
              for l in range(communicator.size):
                  x_ = function(entire_model[l](x_))
              err_ = evaluation(x_, x)
              err_.backward()
              grad_expected = entire_model[0].W.grad
  
              chainer.testing.assert_allclose(grad, grad_expected)
  
          elif communicator.rank == communicator.size - 1:
              # Output process.
              x_ = chainermn.functions.recv(communicator, rank_recv)
              y = function(model(x_))
              err = evaluation(y, x)
              err.backward()
  
              # Compute the expected output.
              x_ = x
              for l in range(communicator.size):
                  x_ = function(entire_model[l](x_))
              y_expect = x_
  
              chainer.testing.assert_allclose(y.data, y_expect.data)
  
          else:
              # Intermediate processes.
              x_ = chainermn.functions.recv(communicator, rank_recv)
              y = function(model(x_))
              err = chainermn.functions.send(y, communicator, rank_send)
              err.backward()
  
imports: import functools
  import chainer
  import copy
  from chainer.backends.cuda import cupy
  import chainer.testing
  import chainer.testing.attr
  import numpy
  import pytest
  import chainermn
  from chainer.functions import sigmoid
  from chainer.functions import mean_squared_error
label_desc: Use image node_id 5 for calling a global function with example usage: check_communication(gpu, param) without return types