code: def check_retain(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:
              # Starting process.
              t = copy.copy(x)
              y = function(model(x))
              dlg = chainermn.functions.send(y, communicator, rank_send)
  
              # Unless delegate_variable is used, backprop would stop here.
              x_ = chainermn.functions.recv(
                  communicator, rank_recv, delegate_variable=dlg
              )
              err = evaluation(x_, t)
              err.backward()
  
              # train.x.grad is None if backprop stops in the middle.
              assert x.grad is not None
  
          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 8 for calling a global function with example usage: check_retain(gpu, param) without return types