code: def rpc_megatron_reuse():
      from fairscale.nn.model_parallel import layers
      from fairscale.nn.model_parallel.initialize import (
          destroy_model_parallel,
          initialize_model_parallel,
      )
  
      def make_model_simple():
          return [
              layers.ColumnParallelLinear(10, 10),
              nn.ReLU(),
              layers.RowParallelLinear(10, 10),
              nn.ReLU(),
              layers.ColumnParallelLinear(10, 10),
              nn.ReLU(),
              layers.RowParallelLinear(10, 10),
              nn.ReLU(),
              nn.Linear(10, 10),
              nn.ReLU(),
          ]
  
      def make_model_with_reuse():
          column = layers.ColumnParallelLinear(10, 10)
          row = layers.RowParallelLinear(10, 10)
          return [
              column,
              nn.ReLU(),
              row,
              nn.ReLU(),
              column,
              nn.ReLU(),
              row,
              nn.ReLU(),
              nn.Linear(10, 10),
              nn.ReLU(),
          ]
  
      destroy_model_parallel()
      torch.distributed.destroy_process_group()
      torch.distributed.init_process_group(
          "gloo",
          rank=int(os.environ["RANK"]),
          world_size=int(os.environ["WORLD_SIZE"]),
      )
      initialize_model_parallel(
          2, 3, model_parallel_backend="nccl", pipeline_backend="mpi"
      )
  
      init_rpc()
      if get_pipeline_parallel_group().rank() != 0:
          rpc.shutdown()
          torch.distributed.barrier()
          return
  
      check_pipe_against_reference(
          [4, 4, 2], make_model_simple, "always"
      )
      check_pipe_against_reference([4, 2, 2], make_model_with_reuse)
  
      rpc.shutdown()
      torch.distributed.barrier()
  
file_path: fairscale/tests/nn/pipe_process/test_rpc.py
imports: import copy
  import os
  import pytest
  import torch
  from torch import nn
  from torch.distributed import rpc
  from fairscale.fair_dev.testing.testing import get_worker_map, torch_spawn
  from fairscale.internal import torch_version
  from fairscale.nn.model_parallel.initialize import get_pipeline_parallel_group
  from fairscale.nn.pipe import PipeRPCWrapper
label_desc: Use image node_id 7 for calling a global function with example usage: rpc_megatron_reuse() and returns: list, list