class_docstr: Computes a Sankey diagram from a Graph element for internal use in
  the Sankey element constructor.
  
  Adapted from d3-sankey under BSD-3 license.
  
  Source: https://github.com/d3/d3-sankey/tree/v0.12.3
class_docstr_tok: ["Computes","a","Sankey","diagram","from","a","Graph","element","for","internal","use","in","the","Sankey","element","constructor",".","Adapted","from","d3-sankey","under","BSD-3","license",".","Source",":","https",":","\/\/github.com\/d3\/d3-sankey\/tree\/v0.12.3"]
code: def layout(self, element, **params):
      self.p = param.ParamOverrides(self, params)
      graph = {"nodes": [], "links": []}
      self.computeNodeLinks(element, graph)
      self.computeNodeValues(graph)
      self.computeNodeDepths(graph)
      self.computeNodeHeights(graph)
      self.computeNodeBreadths(graph)
      self.computeLinkBreadths(graph)
      paths = self.computePaths(graph)
  
      node_data = []
      for node in graph["nodes"]:
          node_data.append(
              (
                  np.mean([node["x0"], node["x1"]]),
                  np.mean([node["y0"], node["y1"]]),
                  node["index"],
              )
              + tuple(node["values"])
          )
      if element.nodes.ndims == 3:
          kdims = element.nodes.kdims
      elif element.nodes.ndims:
          kdims = element.node_type.kdims[:2] + element.nodes.kdims[-1:]
      else:
          kdims = element.node_type.kdims
      nodes = element.node_type(
          node_data, kdims=kdims, vdims=element.nodes.vdims
      )
      edges = element.edge_type(paths)
      return nodes, edges, graph
  
imports: import math
  from functools import cmp_to_key
  from itertools import cycle
  import numpy
  import param
  from ..core.data import Dataset
  from ..core.dimension import Dimension
  from ..core.operation import Operation
  from ..core.util import get_param_values, unique_array
  from .graphs import EdgePaths, Graph, Nodes
  from .util import quadratic_bezier
label_desc: Use image node_id 2 for calling the _layout_sankey obj's underlying member method code with example usage: obj.layout(element) and returns: nodes,  edges,  graph