digraph G {
  label = "simple RNN implementation" 

  ranksep=2;

  //graph [nodesep=1, ranksep=1];

  node[nodesep=1]

  subgraph cluster0 {
    label = "global scope"
    rankdir = TB
    W
    boot_memory
    input
    output
  }

  subgraph cluster1 {
    label = "step-scope 0"
    rankdir = TB
    memory0[label="memory"]
    prememory0[label="pre-memory"]
    step_input0[label="step input"]
    step_output0[label="step output"]
  }

  subgraph cluster2 {
    label = "step-scope 1"
    rankdir = TB
    memory1[label="memory"]
    prememory1[label="pre-memory"]
    step_input1[label="step input"]
    step_output1[label="step output"]
  }

  subgraph cluster3 {
    label = "step-scope 2"
    rankdir = TB
    memory2[label="memory"]
    prememory2[label="pre-memory"]
    step_input2[label="step input"]
    step_output2[label="step output"]
  }

  stepnet [shape=box]
  stepnet0 [shape=box, style=dashed]
  stepnet1 [shape=box, style=dashed]
  stepnet2 [shape=box, style=dashed]


  edge[color=blue]
  boot_memory -> prememory0 [label="init" color="blue"]
  memory0 -> prememory1  [label="copy/reference" color="blue"]
  memory1 -> prememory2 [label="copy/reference" color="blue"]

  edge[color=black]
  W -> stepnet0[constraint=false, style=dashed]
  W -> stepnet1[constraint=false, style=dashed]
  W -> stepnet2[constraint=false, style=dashed]

  memory0 -> stepnet0[style=dashed]
  prememory0 -> stepnet0 -> step_output0[style=dashed]

  memory1 -> stepnet1[style=dashed]
  prememory1 -> stepnet1 -> step_output1[style=dashed]

  memory2 -> stepnet2[style=dashed]
  prememory2 -> stepnet2 -> step_output2[style=dashed]

  input -> step_input0
  input -> step_input1
  input -> step_input2

  step_input0 -> stepnet0 [style=dashed]
  step_input1 -> stepnet1[style=dashed]
  step_input2 -> stepnet2[style=dashed]

  step_output0 -> output
  step_output1 -> output
  step_output2 -> output

  stepnet0 -> stepnet[style=dashed]
  stepnet1 -> stepnet[style=dashed]
  stepnet2 -> stepnet[style=dashed]

}
