'Initializes the bulk bi-LSTM.
Parameters used:
parallel_iterations (1): Parallelism of the underlying tf.while_loop().
Defaults to 1 thread to encourage deterministic behavior, but can be
increased to trade memory for speed.
Args:
component: parent ComponentBuilderBase object.'

def __init__(self, component):

    super(BulkBiLSTMNetwork, self).__init__(component, additional_attr_defaults={'parallel_iterations': 1})
    check.In('lengths', self._linked_feature_dims, 'Missing    required    linked    feature')
    check.Eq(self._linked_feature_dims['lengths'], 1, 'Wrong    dimension    for    "lengths"    feature')
    self._input_dim = (self._concatenated_input_dim - 1)
    self._output_dim = self.get_layer_size('outputs')
    tf.logging.info('[%s]    Bulk    bi-LSTM    with    input_dim=%d    output_dim=%d', component.name, self._input_dim, self._output_dim)
    self._train_cells_forward = self._create_train_cells()
    self._train_cells_backward = self._create_train_cells()
    self._inference_cells_forward = self._create_inference_cells()
    self._inference_cells_backward = self._create_inference_cells()
    def _bilstm_closure(scope):
        'Applies    the    bi-LSTM    to    placeholder    inputs    and    lengths.'
        (stride, steps) = (1, 1)
        placeholder_inputs = tf.placeholder(dtype=tf.float32, shape=[stride, steps, self._input_dim])
        placeholder_lengths = tf.placeholder(dtype=tf.int64, shape=[stride])
        tf.contrib.rnn.stack_bidirectional_dynamic_rnn(self._train_cells_forward, self._train_cells_backward, placeholder_inputs, dtype=tf.float32, sequence_length=placeholder_lengths, scope=scope)
    self._capture_variables_as_params(_bilstm_closure)
    for (index, num_units) in enumerate(self._hidden_layer_sizes):
        for direction in ['forward', 'backward']:
            for substate in ['c', 'h']:
                self._params.append(tf.get_variable(('initial_state_%s_%s_%d' % (direction, substate, index)), [1, num_units], dtype=tf.float32, initializer=tf.constant_initializer(0.0)))
