code: def var_scope(name):
      def decorator(func):
          def wrapper(*args, **kwargs):
              stem = kwargs.get("stem", False)
              scope = kwargs.get("scope", name)
              reuse = kwargs.get("reuse", None)
              with tf.variable_scope(scope, reuse=reuse):
                  x = func(*args, **kwargs)
                  if func.__name__ == "wrapper":
                      from .middles import direct as p0
                      from .preprocess import direct as p1
                      from .pretrained import direct as p2
  
                      _scope = tf.get_variable_scope().name
                      if tf_later_than("1.2"):
                          _name = (
                              tf.get_default_graph().get_name_scope()
                          )
                      else:
                          # Note that `get_middles` and `get_outputs`
                          # may NOT work well for TensorFlow == 1.1.0.
                          _name = _scope
                      if tf_later_than("2"):
                          _input_shape = tuple(args[0].shape[1:3])
                      else:
                          _input_shape = tuple(
                              [i.value for i in args[0].shape[1:3]]
                          )
                      _outs = get_outputs(_name)
                      for i in p0(name)[0]:
                          collect_named_outputs(
                              __middles__, _scope, _outs[i]
                          )
                      if stem:
                          x.aliases.insert(0, _scope)
                          x.p = get_middles(_name)[p0(name)[2]]
                      else:
                          x.logits = get_outputs(_name)[-2]
                      setattr(x, "preprocess", p1(name, _input_shape))
                      setattr(x, "pretrained", p2(name, x))
                      setattr(
                          x,
                          "get_bottleneck",
                          lambda: get_bottleneck(_scope),
                      )
                      setattr(
                          x,
                          "get_middles",
                          lambda names=None: get_middles(_name, names),
                      )
                      setattr(
                          x,
                          "get_outputs",
                          lambda names=None: get_outputs(_name, names),
                      )
                      setattr(
                          x,
                          "get_weights",
                          lambda names=None: get_weights(_scope, names),
                      )
                      setattr(
                          x,
                          "middles",
                          lambda names=None: get_middles(_name, names),
                      )
                      setattr(
                          x,
                          "outputs",
                          lambda names=None: get_outputs(_name, names),
                      )
                      setattr(
                          x,
                          "weights",
                          lambda names=None: get_weights(_scope, names),
                      )
                      setattr(
                          x, "summary", lambda: print_summary(_scope)
                      )
                      setattr(
                          x,
                          "print_middles",
                          lambda: print_middles(_name),
                      )
                      setattr(
                          x,
                          "print_outputs",
                          lambda: print_outputs(_name),
                      )
                      setattr(
                          x,
                          "print_weights",
                          lambda: print_weights(_scope),
                      )
                      setattr(
                          x,
                          "print_summary",
                          lambda: print_summary(_scope),
                      )
                      setattr(
                          x,
                          "init",
                          lambda sess=None: init(_scope, sess),
                      )
                      setattr(
                          x,
                          "load",
                          lambda weights_path, sess=None: load(
                              x, weights_path, sess
                          ),
                      )
                      setattr(
                          x,
                          "save",
                          lambda weights_path, sess=None: save(
                              x, weights_path, sess
                          ),
                      )
                  return x
  
          return wrapper
  
      return decorator
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import numpy
  import tensorflow
  import warnings
  from contextlib import contextmanager
  from .version_utils import tf_later_than
label_desc: Use image node_id 19 for calling a global function with example usage: var_scope(name) and returns: decorator, wrapper, x