code: def _layout(graph, layout=None, *args, **kwds):
      """Returns the layout of the graph according to a layout algorithm.
  
      Parameters and keyword arguments not specified here are passed to the
      layout algorithm directly. See the documentation of the layout
      algorithms for the explanation of these parameters.
  
      Registered layout names understood by this method are:
  
        - C{auto}, C{automatic}: automatic layout
          (see L{Graph.layout_auto})
  
        - C{bipartite}: bipartite layout (see L{GraphBase.layout_bipartite})
  
        - C{circle}, C{circular}: circular layout
          (see L{GraphBase.layout_circle})
  
        - C{dh}, C{davidson_harel}: Davidson-Harel layout (see
          L{GraphBase.layout_davidson_harel})
  
        - C{drl}: DrL layout for large graphs (see L{GraphBase.layout_drl})
  
        - C{drl_3d}: 3D DrL layout for large graphs
          (see L{GraphBase.layout_drl})
  
        - C{fr}, C{fruchterman_reingold}: Fruchterman-Reingold layout
          (see L{GraphBase.layout_fruchterman_reingold}).
  
        - C{fr_3d}, C{fr3d}, C{fruchterman_reingold_3d}: 3D Fruchterman-
          Reingold layout (see L{GraphBase.layout_fruchterman_reingold}).
  
        - C{grid}: regular grid layout in 2D (see L{GraphBase.layout_grid})
  
        - C{grid_3d}: regular grid layout in 3D (see L{GraphBase.layout_grid})
  
        - C{graphopt}: the graphopt algorithm (see L{GraphBase.layout_graphopt})
  
        - C{kk}, C{kamada_kawai}: Kamada-Kawai layout
          (see L{GraphBase.layout_kamada_kawai})
  
        - C{kk_3d}, C{kk3d}, C{kamada_kawai_3d}: 3D Kamada-Kawai layout
          (see L{GraphBase.layout_kamada_kawai})
  
        - C{lgl}, C{large}, C{large_graph}: Large Graph Layout
          (see L{GraphBase.layout_lgl})
  
        - C{mds}: multidimensional scaling layout (see L{GraphBase.layout_mds})
  
        - C{random}: random layout (see L{GraphBase.layout_random})
  
        - C{random_3d}: random 3D layout (see L{GraphBase.layout_random})
  
        - C{rt}, C{tree}, C{reingold_tilford}: Reingold-Tilford tree
          layout (see L{GraphBase.layout_reingold_tilford})
  
        - C{rt_circular}, C{reingold_tilford_circular}: circular
          Reingold-Tilford tree layout
          (see L{GraphBase.layout_reingold_tilford_circular})
  
        - C{sphere}, C{spherical}, C{circle_3d}, C{circular_3d}: spherical
          layout (see L{GraphBase.layout_circle})
  
        - C{star}: star layout (see L{GraphBase.layout_star})
  
        - C{sugiyama}: Sugiyama layout (see L{Graph.layout_sugiyama})
  
      @param layout: the layout to use. This can be one of the registered
        layout names or a callable which returns either a L{Layout} object or
        a list of lists containing the coordinates. If C{None}, uses the
        value of the C{plotting.layout} configuration key.
      @return: a L{Layout} object.
      """
      # Deferred import to avoid cycles
      from igraph import config
  
      if layout is None:
          layout = config["plotting.layout"]
      if callable(layout):
          method = layout
      else:
          layout = layout.lower()
          if layout[-3:] == "_3d":
              kwds["dim"] = 3
              layout = layout[:-3]
          elif layout[-2:] == "3d":
              kwds["dim"] = 3
              layout = layout[:-2]
          method = getattr(
              graph.__class__, graph._layout_mapping[layout]
          )
      if not callable(method):
          raise ValueError("layout method must be callable")
      layout = method(graph, *args, **kwds)
      if not isinstance(layout, Layout):
          layout = Layout(layout)
      return layout
  
imports: from math import sin, cos, pi
  from igraph._igraph import GraphBase
  from igraph.drawing.utils import BoundingBox
  from igraph.statistics import RunningMean
label_desc: Use image node_id 1 for calling a global function with example usage: _layout(graph, layout) and returns: layout