code: def execute_replication_callbacks(modules):
      """
      Execute an replication callback `__data_parallel_replicate__` on each module created
      by original replication.
  
      The callback will be invoked with arguments `__data_parallel_replicate__(ctx, copy_id)`
  
      Note that, as all modules are isomorphism, we assign each sub-module with a context
      (shared among multiple copies of this module on different devices).
      Through this context, different copies can share some information.
  
      We guarantee that the callback on the master copy (the first copy) will be called ahead
      of calling the callback of any slave copies.
      """
      master_copy = modules[0]
      nr_modules = len(list(master_copy.modules()))
      ctxs = [CallbackContext() for _ in range(nr_modules)]
  
      for i, module in enumerate(modules):
          for j, m in enumerate(module.modules()):
              if hasattr(m, "__data_parallel_replicate__"):
                  m.__data_parallel_replicate__(ctxs[j], i)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import functools
  import threading
  import torch
  import torch.cuda.comm
  from torch.autograd import Variable, Function
  from torch.nn.parallel.data_parallel import DataParallel
  from torch.nn.parallel.parallel_apply import get_a_var
  from torch.nn.parallel._functions import ReduceAddCoalesced, Broadcast
label_desc: Use image node_id 3 for calling a global function with example usage: execute_replication_callbacks(modules) without return types