code: def feed_forward_layers(inputs, outputs, connections):
      
  
      required = required_for_output(inputs, outputs, connections)
  
      layers = []
      s = set(inputs)
      while 1:
          # Find candidate nodes c for the next layer.  These nodes should connect
          # a node in s to a node not in s.
          c = set(b for (a, b) in connections if a in s and b not in s)
          # Keep only the used nodes whose entire input set is contained in s.
          t = set()
          for n in c:
              if n in required and all(a in s for (a, b) in connections if b == n):
                  t.add(n)
  
          if not t:
              break
  
          layers.append(t)
          s = s.union(t)
  
      return layers
docs: Collect the layers whose members can be evaluated in parallel in a feed-forward network.
      :param inputs: list of the network input nodes
      :param outputs: list of the output node identifiers
      :param connections: list of (input, output) connections in the network.
  
      Returns a list of layers, with each layer consisting of a set of node identifiers.
      Note that the returned layers do not contain nodes whose output is ultimately
      never used to compute the final network output.