code: def create_sequence_pipeline(
      layers: List[RemoteModuleParams],
      balance: List[int],
      devices: List[str],
      **kwargs: Any,
  ) -> DistributedPipeline:
      """A simple helper function to create a pipeline from list of pipeline-modules that run sequentially.
      Args:
          layers: list of modules. They should not be already assigned a remote-device.
          balance: a list of integers how layers should be paritioned. Sum of numbers in 'balance'
              should be equal to the number of layers.
          devices: specification of remote device for each partition. Should be of the same length
              as 'balance'.
      """
      remote_modules: List[RemoteModule] = []
      index = 0
      for num_layers, remote_device in zip(balance, devices):
          next_index = index + num_layers
          for li in range(index, next_index):
              remote_modules.append(
                  RemoteModule(remote_device, **layers[li]._asdict())
              )
          index = next_index
  
      graph = PipelineModulesGraph()
      graph.add_sequence(remote_modules, [0])
  
      return DistributedPipeline(graph, **kwargs)
  
imports: import functools
  import tempfile
  from typing import Any, Dict, List, NamedTuple, Tuple
  import pytest
  import torch
  import torch.distributed.autograd
  from torch.distributed.nn import RemoteModule
  from torch.distributed.optim import DistributedOptimizer
  import torch.distributed.rpc
  import torch.multiprocessing
  import torch.nn
  from fairscale.experimental.nn.distributed_pipeline import DistributedLoss, DistributedPipeline, PipelineModulesGraph
  from fairscale.fair_dev.testing.testing import skip_due_to_flakyness, skip_if_single_gpu
  from fairscale.internal import torch_version
label_desc: Use image node_id 2 for calling a global function with example usage: create_sequence_pipeline(layers, balance, devices) and returns: DistributedPipeline