code: def unroll_scan(fn, sequence, outputs_info):
      """
      Helper function to unroll for loops. Can be used to unroll
      ``tensorflow.scan``.
  
      Parameters
      ----------
      fn : function
          Function that defines calculations at each step.
  
      sequences : TensorVariable or list of TensorVariables
          List of TensorVariable with sequence data. The function iterates
          over the first dimension of each TensorVariable.
  
      outputs_info : list of TensorVariables
          List of tensors specifying the initial values for each recurrent
          value.
  
      Returns
      -------
      List of TensorVariables. Each element in the list gives
      the recurrent values at each time step.
      """
      with tf.name_scope("unroll-scan"):
          outputs = []
          prev_vals = outputs_info
  
          for entity in tf.unstack(sequence):
              output = fn(prev_vals, entity)
              outputs.append(output[-1])
              prev_vals = output
  
          return tf.stack(outputs)
  
imports: import types
  import tensorflow
  from neupy import init
  from neupy.utils import tensorflow_session
  from neupy.exceptions import LayerConnectionError
  from neupy.core.properties import IntProperty, Property, NumberProperty, ParameterProperty
  from .base import BaseLayer
label_desc: Use image node_id 2 for calling a global function with example usage: unroll_scan(fn, sequence, outputs_info) and returns: tf