code: def layer(op):
      """Decorator for composable network layers."""
  
      def layer_decorated(self, *args, **kwargs):
          # Automatically set a name if not provided.
          name = kwargs.setdefault(
              "name", self.get_unique_name(op.__name__)
          )
          # Figure out the layer inputs.
          if len(self.terminals) == 0:
              raise RuntimeError(
                  "No input variables found for layer %s." % name
              )
          elif len(self.terminals) == 1:
              layer_input = self.terminals[0]
          else:
              layer_input = list(self.terminals)
  
          # Perform the operation and get the output.
          layer_output = op(self, layer_input, *args, **kwargs)
          # Add to layer LUT.
          self.layers[name] = layer_output
          # This output is now the input for the next layer.
          self.feed(layer_output)
          # Return self for chained calls.
          return self
  
      return layer_decorated
  
imports: from __future__ import print_function
  from builtins import str
  from past.builtins import basestring
  from builtins import object
  import sys
  import os
  import math
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: layer(op) and returns: layer_decorated, self