code: def sg_sugar_func(func):
      r
      @wraps(func)
      def wrapper(tensor, **kwargs):
          # call sugar function
          out = func(tensor, tf.sg_opt(kwargs))
          # save node info for reuse
          out._sugar = tf.sg_opt(func=func, arg=tf.sg_opt(kwargs)+sg_get_context(), prev=tensor)
          # inject reuse function
          out.sg_reuse = types.MethodType(sg_reuse, out)
          return out
  
      return wrapper
docs: r""" Decorates a function `func` so that it can be a sugar function.
      Sugar function can be used in a chainable manner.
  
      Args:
          func: function to decorate
  
      Returns:
        A sugar function.