'Applies a function using previously-captured variables.
Args:
function: Function to apply using captured variables.  The function
should take one argument, its enclosing variable scope.
Returns:
Results of function application.'

def _apply_with_captured_variables(self, function):

    def _custom_getter(getter, *args, **kwargs):
        'Retrieves    the    normal    or    moving-average    variables.'
        return self._component.get_variable(var_params=getter(*args, **kwargs))
    with tf.variable_scope('cell', reuse=True, custom_getter=_custom_getter) as scope:
        return function(scope)
