'Ensures ComputeSession is released before outputs are returned.
Args:
handle: Handle to ComputeSession on which all computation until now has
depended. It will be released and assigned to the output \'run\'.
inputs: list of nodes we want to pass through without any dependencies.
outputs: list of nodes whose access should ensure the ComputeSession is
safely released.
Returns:
A dictionary of both input and output nodes.'

def _outputs_with_release(self, handle, inputs, outputs):

    with tf.control_dependencies(outputs.values()):
        with tf.name_scope('ComputeSession'):
            release_op = dragnn_ops.release_session(handle)
        run_op = tf.group(release_op, name='run')
        for output in outputs:
            with tf.control_dependencies([release_op]):
                outputs[output] = tf.identity(outputs[output], name=output)
    all_nodes = inputs.copy()
    all_nodes.update(outputs)
    all_nodes['run'] = run_op
    return all_nodes
