code: def sequential_like(balance, pipe_class):
      a = nn.Linear(1, 1)
      b = nn.Linear(1, 1)
  
      model = nn.Sequential(a, b)
      model = pipe_class(model, balance, worker_map=get_worker_map())
  
      if balance == [2]:
          if torch.distributed.get_rank() == 0:
              assert len(model) == 2
              assert list(model) == [a, b]
  
              assert model[0] is a
              assert model[1] is b
              with pytest.raises(IndexError):
                  _ = model[2]
  
              assert model[-1] is b
              assert model[-2] is a
          else:
              assert len(model) == 0
              assert list(model) == []
      else:
          assert len(model) == 1
          if torch.distributed.get_rank() == 0:
              assert list(model) == [a]
              assert model[0] is a
              assert model[-1] is a
          else:
              assert list(model) == [b]
              assert model[0] is b
              assert model[-1] is b
  
          with pytest.raises(IndexError):
              _ = model[1]
  
imports: from collections import OrderedDict
  from copy import deepcopy
  import os
  import time
  import pytest
  import torch
  from torch import nn
  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 AsyncPipe
  from fairscale.nn.pipe.types import LazyModule
label_desc: Use image node_id 7 for calling a global function with example usage: sequential_like(balance, pipe_class) without return types