code: def multipartite_layout(
      G, subset_key="subset", align="vertical", scale=1, center=None
  ):
      """Position nodes in layers of straight lines.
  
      Parameters
      ----------
      G : NetworkX graph or list of nodes
          A position will be assigned to every node in G.
  
      subset_key : string (default='subset')
          Key of node data to be used as layer subset.
  
      align : string (default='vertical')
          The alignment of nodes. Vertical or horizontal.
  
      scale : number (default: 1)
          Scale factor for positions.
  
      center : array-like or None
          Coordinate pair around which to center the layout.
  
      Returns
      -------
      pos : dict
          A dictionary of positions keyed by node.
  
      Examples
      --------
      >>> G = nx.complete_multipartite_graph(28, 16, 10)
      >>> pos = nx.multipartite_layout(G)
  
      Notes
      -----
      This algorithm currently only works in two dimensions and does not
      try to minimize edge crossings.
  
      Network does not need to be a complete multipartite graph. As long as nodes
      have subset_key data, they will be placed in the corresponding layers.
  
      """
      import numpy as np
  
      if align not in ("vertical", "horizontal"):
          msg = "align must be either vertical or horizontal."
          raise ValueError(msg)
  
      G, center = _process_params(G, center=center, dim=2)
      if len(G) == 0:
          return {}
  
      layers = {}
      for v, data in G.nodes(data=True):
          try:
              layer = data[subset_key]
          except KeyError:
              msg = "all nodes must have subset_key (default='subset') as data"
              raise ValueError(msg)
          layers[layer] = [v] + layers.get(layer, [])
  
      # Sort by layer, if possible
      try:
          layers = sorted(layers.items())
      except TypeError:
          layers = list(layers.items())
  
      pos = None
      nodes = []
      width = len(layers)
      for i, (_, layer) in enumerate(layers):
          height = len(layer)
          xs = np.repeat(i, height)
          ys = np.arange(0, height, dtype=float)
          offset = ((width - 1) / 2, (height - 1) / 2)
          layer_pos = np.column_stack([xs, ys]) - offset
          if pos is None:
              pos = layer_pos
          else:
              pos = np.concatenate([pos, layer_pos])
          nodes.extend(layer)
      pos = rescale_layout(pos, scale=scale) + center
      if align == "horizontal":
          pos = pos[:, ::-1]  # swap x and y coords
      pos = dict(zip(nodes, pos))
      return pos
  
imports: import networkx
  from networkx.utils import np_random_state
label_desc: Use image node_id 17 for calling a global function with example usage: multipartite_layout(G, subset_key, align, scale, center) and returns: pos, dict