def clone_get_equiv(inputs, outputs, copy_inputs_and_orphans=True, memo=None):
 if (memo is None):
  memo = {}
 for input in inputs:
  if copy_inputs_and_orphans:
   cpy = input.clone()
   cpy.owner = None
   cpy.index = None
   memo.setdefault(input, cpy)
  else:
   memo.setdefault(input, input)
 for apply in io_toposort(inputs, outputs):
  for input in apply.inputs:
   if (input not in memo):
    if copy_inputs_and_orphans:
     cpy = input.clone()
     memo[input] = cpy
    else:
     memo[input] = input
  new_apply = apply.clone_with_new_inputs([memo[i] for i in apply.inputs])
  memo.setdefault(apply, new_apply)
  for (output, new_output) in zip(apply.outputs, new_apply.outputs):
   memo.setdefault(output, new_output)
 for output in outputs:
  if (output not in memo):
   memo[output] = output.clone()
 return memo

def clone_get_equiv ( inputs , outputs , copy_inputs_and_orphans = True , memo = None ) : if ( memo is None ) : memo = { } for input in inputs : if copy_inputs_and_orphans : cpy = input . clone ( ) cpy . owner = None cpy . index = None memo . setdefault ( input , cpy ) else : memo . setdefault ( input , input ) for apply in io_toposort ( inputs , outputs ) : for input in apply . inputs : if ( input not in memo ) : if copy_inputs_and_orphans : cpy = input . clone ( ) memo [ input ] = cpy else : memo [ input ] = input new_apply = apply . clone_with_new_inputs ( [ memo [ i ] for i in apply . inputs ] ) memo . setdefault ( apply , new_apply ) for ( output , new_output ) in zip ( apply . outputs , new_apply . outputs ) : memo . setdefault ( output , new_output ) for output in outputs : if ( output not in memo ) : memo [ output ] = output . clone ( ) return memo
return a dictionary that maps from variable and apply nodes in the original graph to a new node in a new graph .