# Buggy code
def autoflow_wrapper(method):
    @functools.wraps(method)
    def runnable(obj, *args, **kwargs):
        if not isinstance(obj, Node):
            raise GPflowError("AutoFlow works only with node-like objects.")
        if obj.is_built_coherence(obj.graph) is Build.NO:
            raise GPflowError('Not built with "{graph}".'.format(graph=obj.graph))
        name = method.__name__
        store = AutoFlow.get_autoflow(obj, name)
        session = kwargs.pop("session", None)
        session = obj.enquire_session(session=session)
        if not store:
            scope_name = _name_scope_name(obj, name)
            with session.graph.as_default(), tf.name_scope(scope_name):
                _setup_storage(store, *af_args, **af_kwargs)
                _build_method(method, obj, store)
        return _session_run(session, obj, store, *args, **kwargs)

    return runnable


# Traceback (AttributeError)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-3-e3c07a8fceb7> in <module>()
10                                 np.random.randn(M, D),
11                                 minibatch_size=2)
---> 12 model.compute_log_likelihood()

/[...]/GPflow/gpflow/decors.py in runnable(obj, *args, **kwargs)
152                     _setup_storage(store, *af_args, **af_kwargs)
153                     _build_method(method, obj, store)
--> 154             return _session_run(session, obj, store, *args, **kwargs)
155         return runnable
156     return autoflow_wrapper

/[...]/GPflow/gpflow/decors.py in _session_run(session, obj, store, *args, **kwargs)
189         feed_dict.update(obj.feeds)
190     initialize = kwargs.pop('initialize', False)
--> 191     obj.initialize(session=session, force=initialize)
192     return session.run(store['result'], **kwargs)
193

/[...]/GPflow/gpflow/core/node.py in initialize(self, session, force)
82                 session=session,
83                 force=force,
---> 84                 feed_dict=self.initializable_feeds)
85
86     def clear(self):

/[...]/GPflow/gpflow/misc.py in initialize_variables(variables, session, force, **run_kwargs)
82             initializer = tf.variables_initializer(variables)
83         else:
---> 84             uninitialized = tf.report_uninitialized_variables(var_list=variables)
85             def uninitialized_names():
86                 for uv in session.run(uninitialized):

/[...]/anaconda3/envs/py35cpu/lib/python3.5/site-packages/tensorflow/python/util/tf_should_use.py in wrapped(*args, **kwargs)
105   """
106   def wrapped(*args, **kwargs):
--> 107     return _add_should_use_warning(fn(*args, **kwargs))
108   return tf_decorator.make_decorator(
109       fn, wrapped, 'should_use_result',

/[...]/anaconda3/envs/py35cpu/lib/python3.5/site-packages/tensorflow/python/ops/variables.py in report_uninitialized_variables(var_list, name)
1519         variables_mask = math_ops.logical_not(
1520             array_ops.stack(
-> 1521                 [state_ops.is_variable_initialized(v) for v in var_list]))
1522         # Get a 1-D string tensor containing all the variable names.
1523         variable_names_tensor = array_ops.constant(

/[...]/anaconda3/envs/py35cpu/lib/python3.5/site-packages/tensorflow/python/ops/variables.py in <listcomp>(.0)
1519         variables_mask = math_ops.logical_not(
1520             array_ops.stack(
-> 1521                 [state_ops.is_variable_initialized(v) for v in var_list]))
1522         # Get a 1-D string tensor containing all the variable names.
1523         variable_names_tensor = array_ops.constant(

/[...]/anaconda3/envs/py35cpu/lib/python3.5/site-packages/tensorflow/python/ops/state_ops.py in is_variable_initialized(ref, name)
182     A `Tensor` of type `bool`.
183   """
--> 184   if ref.dtype._is_ref_dtype:
185     return gen_state_ops.is_variable_initialized(ref=ref, name=name)
186   # Handle resource variables.

AttributeError: 'Iterator' object has no attribute 'dtype'

# Fixed code
def autoflow_wrapper(method):
    @functools.wraps(method)
    def runnable(obj, *args, **kwargs):
        if not isinstance(obj, Node):
            raise GPflowError("AutoFlow works only with node-like objects.")
        if obj.is_built_coherence(obj.graph) is Build.NO:
            raise GPflowError('Not built with "{graph}".'.format(graph=obj.graph))
        name = method.__name__
        store = AutoFlow.get_autoflow(obj, name)
        session = kwargs.pop("session", None)
        session = obj.enquire_session(session=session)

        scope_name = _name_scope_name(obj, name)
        with session.graph.as_default(), tf.name_scope(scope_name):
            if not store:
                _setup_storage(store, *af_args, **af_kwargs)
                _build_method(method, obj, store)
            return _session_run(session, obj, store, *args, **kwargs)

    return runnable