# Buggy code
def create_variables(self, optimizer=None):
    """Creates the model variables by running it once.

    Args:
      optimizer: If set, also create the optimizer variables.
    """
    if self.built:
        return

    # Create input features from the input signatures. We remove the leading
    # batch dimension as sometimes assumed by make_features methods and set
    # unspecified dimensions to 1.
    features = tf.nest.map_structure(
        lambda spec: tf.fill(
            [dim or 1 for dim in spec.shape.as_list()[1:]],
            tf.constant("" if spec.dtype is tf.string else 1, dtype=spec.dtype),
        ),
        self.examples_inputter.input_signature(),
    )
    features = self.examples_inputter.make_features(features=features, training=True)

    # Add the batch dimension back before calling the model.
    features, labels = tf.nest.map_structure(lambda x: tf.expand_dims(x, 0), features)
    _ = self(features, labels=labels, training=True, step=0)

    if optimizer is not None:
        _ = optimizer.iterations
        optimizer._create_hypers()  # pylint: disable=protected-access
        optimizer._create_slots(self.trainable_variables)  # pylint: disable=protected-access


# Traceback (TypeError)
Traceback (most recent call last):
File "/usr/local/bin/onmt-main", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.5/dist-packages/opennmt/bin/main.py", line 189, in main
checkpoint_path=args.checkpoint_path)
File "/usr/local/lib/python3.5/dist-packages/opennmt/runner.py", line 205, in train
export_on_best=eval_config.get("export_on_best"))
File "/usr/local/lib/python3.5/dist-packages/opennmt/training.py", line 70, in __call__
self._model.create_variables(optimizer=self._optimizer)
File "/usr/local/lib/python3.5/dist-packages/opennmt/models/model.py", line 271, in create_variables
features = self.examples_inputter.make_features(features=features, training=True)
File "/usr/local/lib/python3.5/dist-packages/opennmt/models/sequence_to_sequence.py", line 426, in make_features
element, alignment = element
TypeError: 'NoneType' object is not iterable

# Fixed code
def create_variables(self, optimizer=None):
    """Creates the model variables by running it once.

    Args:
      optimizer: If set, also create the optimizer variables.
    """
    if self.built:
        return

    # Create input features from the input signatures. We remove the leading
    # batch dimension as sometimes assumed by make_features methods and set
    # unspecified dimensions to 1.
    features = tf.nest.map_structure(
        lambda spec: tf.fill(
            [dim or 1 for dim in spec.shape.as_list()[1:]],
            tf.constant("" if spec.dtype is tf.string else 1, dtype=spec.dtype),
        ),
        self.examples_inputter.input_signature(),
    )
    features = self.examples_inputter.make_features(features=features)

    # Add the batch dimension back before calling the model.
    features, labels = tf.nest.map_structure(lambda x: tf.expand_dims(x, 0), features)
    _ = self(features, labels=labels, training=True, step=0)

    if optimizer is not None:
        _ = optimizer.iterations
        optimizer._create_hypers()  # pylint: disable=protected-access
        optimizer._create_slots(self.trainable_variables)  # pylint: disable=protected-access