This decorator wraps a function so that it runs inside a TensorFlow
    name scope. The name is given by the `name` option; if this is None,
    then the name of the function will be used.
    ```
    >>> @name_scope()
    >>> def foo(...):
    >>>     # now runs inside scope "foo"
    >>> @name_scope('bar')
    >>> def baz(...):
    >>>     # now runs inside scope "bar", not "baz"
    ```

def name_scope(name=None):
    """
    This decorator wraps a function so that it runs inside a TensorFlow
    name scope. The name is given by the `name` option; if this is None,
    then the name of the function will be used.
    ```
    >>> @name_scope()
    >>> def foo(...):
    >>>     # now runs inside scope "foo"
    >>> @name_scope('bar')
    >>> def baz(...):
    >>>     # now runs inside scope "bar", not "baz"
    ```
    """
    def name_scope_wrapper_decorator(method):
        @functools.wraps(method)
        def name_scope_wrapper(*args, **kwargs):
            scope_name = name if name is not None else method.__name__
            with tf.name_scope(scope_name):
                return method(*args, **kwargs)
        return name_scope_wrapper
    return name_scope_wrapper_decorator