def Interface(ys, xs):
 if isinstance(ys, (list, tuple)):
  queue = list(ys)
 else:
  queue = [ys]
 out = OrderedDict()
 if isinstance(xs, (list, tuple)):
  for x in xs:
   out[x] = []
 else:
  out[xs] = []
 done = set()
 while queue:
  y = queue.pop()
  if (y in done):
   continue
  done = done.union(set([y]))
  for x in y.op.inputs:
   if (x in out):
    out[x].append(y)
   else:
    assert (id(x) not in [id(foo) for foo in out])
  queue.extend(y.op.inputs)
 return out

def Interface ( ys , xs ) : if isinstance ( ys , ( list , tuple ) ) : queue = list ( ys ) else : queue = [ ys ] out = OrderedDict ( ) if isinstance ( xs , ( list , tuple ) ) : for x in xs : out [ x ] = [ ] else : out [ xs ] = [ ] done = set ( ) while queue : y = queue . pop ( ) if ( y in done ) : continue done = done . union ( set ( [ y ] ) ) for x in y . op . inputs : if ( x in out ) : out [ x ] . append ( y ) else : assert ( id ( x ) not in [ id ( foo ) for foo in out ] ) queue . extend ( y . op . inputs ) return out
maps xs to consumers .