parameters: (inputs, outputs, name=None)
return_statement: return decorator
docstring: Decorator to turn a function into a loom op.
  
    Example usage:
  
        @as_loom_op((in0_ts, in1_ts), out_ts)
        def foo(in0, in1):
          return in0 + in1
  
        @as_loom_op((in0_ts, in1_ts), (out0_ts, out1_ts))
        def bar(in0, in1):
          return in0 + in1, in1 - in0
  
    A single use of @as_loom_op reuses one variable_scope if used multiple times
    by TensorLoom, so any variables created by layers will be shared.  This
    happens if max_depth != None in TensorLoom.  If you want multiple independent
    sets of variables, make a function that decorates a nested function with
    @as_loom_op:
  
        def merge(arity):
          @as_loom_op([in_ts] * arity, out_ts)
          def merge(*args):
            return layers.relu(tf.concat(1, args), size)
          return merge
        op1 = merge(1)
        op2 = merge(2)
  
    Args:
      inputs: Input type shapes (either a list or a single type shape).
      outputs: Output type shapes (either a list or a single type shape).  If a
          single type shape is given, the function should return a single Tensor.
      name: Name scope (defaults to `f.__name__`).
  
    Returns:
      A decorator to apply to the instantiate batch function (see examples).
docstring_summary: Decorator to turn a function into a loom op.
docstring_tokens: Decorator to turn a function into a loom op .
function: def as_loom_op(inputs, outputs, name=None):
    """Decorator to turn a function into a loom op.
  
    Example usage:
  
        @as_loom_op((in0_ts, in1_ts), out_ts)
        def foo(in0, in1):
          return in0 + in1
  
        @as_loom_op((in0_ts, in1_ts), (out0_ts, out1_ts))
        def bar(in0, in1):
          return in0 + in1, in1 - in0
  
    A single use of @as_loom_op reuses one variable_scope if used multiple times
    by TensorLoom, so any variables created by layers will be shared.  This
    happens if max_depth != None in TensorLoom.  If you want multiple independent
    sets of variables, make a function that decorates a nested function with
    @as_loom_op:
  
        def merge(arity):
          @as_loom_op([in_ts] * arity, out_ts)
          def merge(*args):
            return layers.relu(tf.concat(1, args), size)
          return merge
        op1 = merge(1)
        op2 = merge(2)
  
    Args:
      inputs: Input type shapes (either a list or a single type shape).
      outputs: Output type shapes (either a list or a single type shape).  If a
          single type shape is given, the function should return a single Tensor.
      name: Name scope (defaults to `f.__name__`).
  
    Returns:
      A decorator to apply to the instantiate batch function (see examples).
    """
    if isinstance(inputs, loom.TypeShape):
      inputs = inputs,
    single_output = isinstance(outputs, loom.TypeShape)
    if single_output:
      outputs = outputs,
  
    def decorator(f):
      """Decorator to turn a function into a loom op."""
      # Make a fresh scope.  We do this here so that it happens at decorator
      # time so that scope names do not depend on the order in which TensorLoom
      # calls instantiate_batch.
      scope_name = f.__name__ if name is None else name
      with tf.variable_scope(None, scope_name) as scope:
  
        class AsLoomOp(loom.LoomOp):
  
          def __init__(self):
            super(AsLoomOp, self).__init__(inputs, outputs)
            self._reuse = False
  
          def instantiate_batch(self, tensors):
            with tf.variable_scope(scope, reuse=self._reuse):
              self._reuse = True
              tensors = f(*tensors)
              return (tensors,) if single_output else tensors
  
        return AsLoomOp()
  
    return decorator
function_tokens: def as_loom_op ( inputs , outputs , name = None ) : if isinstance ( inputs , loom . TypeShape ) : inputs = inputs , single_output = isinstance ( outputs , loom . TypeShape ) if single_output : outputs = outputs , def decorator ( f ) : """Decorator to turn a function into a loom op.""" # Make a fresh scope.  We do this here so that it happens at decorator # time so that scope names do not depend on the order in which TensorLoom # calls instantiate_batch. scope_name = f . __name__ if name is None else name with tf . variable_scope ( None , scope_name ) as scope : class AsLoomOp ( loom . LoomOp ) : def __init__ ( self ) : super ( AsLoomOp , self ) . __init__ ( inputs , outputs ) self . _reuse = False def instantiate_batch ( self , tensors ) : with tf . variable_scope ( scope , reuse = self . _reuse ) : self . _reuse = True tensors = f ( * tensors ) return ( tensors , ) if single_output else tensors return AsLoomOp ( ) return decorator