# Buggy code
def _combine_sparse_dense_features(
    self,
    features: List[Union[tf.Tensor, tf.SparseTensor]],
    mask: tf.Tensor,
    name: Text,
) -> tf.Tensor:
    dense_features = []

    dense_dim = self.dense_dim[name]
    # if dense features are present use the feature dimension of the dense features
    for f in features:
        if not isinstance(f, tf.SparseTensor):
            dense_dim = f.shape[-1]
            break

    for f in features:
        if isinstance(f, tf.SparseTensor):
            dense_features.append(
                train_utils.tf_dense_layer_for_sparse(f, dense_dim, name, self.C2)
            )
        else:
            dense_features.append(f)

    output = tf.concat(dense_features, axis=-1) * mask
    output = tf.squeeze(output, axis=1)

    return output


# Traceback (tensorflow.python.framework.errors_impl.InvalidArgumentError)
2020-01-30 16:57:43 INFO     rasa.nlu.utils.spacy_utils  - Trying to load spacy model with name 'de_core_news_sm'
2020-01-30 16:57:44 INFO     transformers.file_utils  - PyTorch version 1.3.0+cpu available.
2020-01-30 16:57:44 INFO     transformers.modeling_xlnet  - Better speed can be achieved with apex installed from https://www.github.com/nvidia/apex .
2020-01-30 16:57:45 INFO     rasa.nlu.components  - Added 'SpacyNLP' to component cache. Key 'SpacyNLP-de_core_news_sm'.
2020-01-30 16:57:45 INFO     rasa.nlu.utils.spacy_utils  - Trying to load spacy model with name 'de_core_news_md'
2020-01-30 16:58:26 INFO     rasa.nlu.components  - Added 'SpacyNLP' to component cache. Key 'SpacyNLP-de_core_news_md'.
2020-01-30 16:58:26 INFO     rasa.nlu.training_data.training_data  - Training data stats:
- intent examples: 347 (18 distinct intents)
- Found intents: 'repeat_last_question', 'functions', 'deny+utter_mobilenumber', 'deny', 'utter_mobilenumber', 'confirm', 'reset_dialog', 'ask_outofscope', 'deny_appointment_suggestion', 'ask_repeat_contact', 'make_appointment', 'not_now', 'greet', 'goodbye', 'thankyou', 'ask_persisted_user_data', 'persist_purpose', 'select_appointment_slot'
- Number of response examples: 0 (0 distinct response)
- entity examples: 104 (7 distinct entities)
- found entities: 'appointment_type', 'daytime', 'not_now_reason', 'slot_shift', 'mobilenumber', 'time', 'employee'

2020-01-30 16:58:26 INFO     rasa.nlu.model  - Starting to train component SpacyNLP
2020-01-30 16:58:26 INFO     rasa.nlu.model  - Finished training component.
2020-01-30 16:58:26 INFO     rasa.nlu.model  - Starting to train component SpacyTokenizer
2020-01-30 16:58:26 INFO     rasa.nlu.model  - Finished training component.
2020-01-30 16:58:26 INFO     rasa.nlu.model  - Starting to train component CountVectorsFeaturizer
2020-01-30 16:58:26 INFO     rasa.nlu.model  - Finished training component.
2020-01-30 16:58:26 INFO     rasa.nlu.model  - Starting to train component CountVectorsFeaturizer
2020-01-30 16:58:27 INFO     rasa.nlu.model  - Finished training component.
2020-01-30 16:58:27 INFO     rasa.nlu.model  - Starting to train component SpacyFeaturizer
2020-01-30 16:58:27 INFO     rasa.nlu.model  - Finished training component.
2020-01-30 16:58:27 INFO     rasa.nlu.model  - Starting to train component EmbeddingIntentClassifier
Tensor("mul:0", shape=(?, ?, 192), dtype=float32)
Tensor("mul_1:0", shape=(?, ?, 20), dtype=float32)
Tensor("mul_2:0", shape=(18, 2, 20), dtype=float32)
Traceback (most recent call last):
File "c:\users\\envs\eva_env\lib\site-packages\tensorflow_core\python\framework\ops.py", line 1607, in _create_c_op
c_op = c_api.TF_FinishOperation(op_desc)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Can not squeeze dim[1], expected a dimension of 1, got 2 for 'Squeeze_2' (op: 'Squeeze') with input shapes: [18,2,20].

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\users\\appdata\local\programs\python\python36\Lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\users\\appdata\local\programs\python\python36\Lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\\Envs\eva_env\Scripts\rasa.exe\__main__.py", line 7, in <module>
File "c:\users\\envs\eva_env\lib\site-packages\rasa\__main__.py", line 76, in main
cmdline_arguments.func(cmdline_arguments)
File "c:\users\\envs\eva_env\lib\site-packages\rasa\cli\train.py", line 76, in train
additional_arguments=extract_additional_arguments(args),
File "c:\users\\envs\eva_env\lib\site-packages\rasa\train.py", line 50, in train
additional_arguments=additional_arguments,
File "c:\users\\appdata\local\programs\python\python36\Lib\asyncio\base_events.py", line 484, in run_until_complete
return future.result()
File "c:\users\\envs\eva_env\lib\site-packages\rasa\train.py", line 101, in train_async
additional_arguments,
File "c:\users\\envs\eva_env\lib\site-packages\rasa\train.py", line 188, in _train_async_internal
additional_arguments=additional_arguments,
File "c:\users\\envs\eva_env\lib\site-packages\rasa\train.py", line 245, in _do_training
persist_nlu_training_data=persist_nlu_training_data,
File "c:\users\\envs\eva_env\lib\site-packages\rasa\train.py", line 474, in _train_nlu_with_validated_data
persist_nlu_training_data=persist_nlu_training_data,
File "c:\users\\envs\eva_env\lib\site-packages\rasa\nlu\train.py", line 86, in train
interpreter = trainer.train(training_data, **kwargs)
File "c:\users\\envs\eva_env\lib\site-packages\rasa\nlu\model.py", line 191, in train
updates = component.train(working_data, self.config, **context)
File "c:\users\\envs\eva_env\lib\site-packages\rasa\nlu\classifiers\embedding_intent_classifier.py", line 769, in train
loss, acc = self._build_tf_train_graph(session_data)
File "c:\users\\envs\eva_env\lib\site-packages\rasa\nlu\classifiers\embedding_intent_classifier.py", line 571, in _build_tf_train_graph
label_data["label_features"], label_data["label_mask"][0], "label"
File "c:\users\\envs\eva_env\lib\site-packages\rasa\nlu\classifiers\embedding_intent_classifier.py", line 547, in _combine_sparse_dense_features
output = tf.squeeze(output, axis=1)
File "c:\users\\envs\eva_env\lib\site-packages\tensorflow_core\python\util\dispatch.py", line 180, in wrapper
return target(*args, **kwargs)
File "c:\users\\envs\eva_env\lib\site-packages\tensorflow_core\python\util\deprecation.py", line 507, in new_func
return func(*args, **kwargs)
File "c:\users\\envs\eva_env\lib\site-packages\tensorflow_core\python\ops\array_ops.py", line 3651, in squeeze
return gen_array_ops.squeeze(input, axis, name)
File "c:\users\\envs\eva_env\lib\site-packages\tensorflow_core\python\ops\gen_array_ops.py", line 10068, in squeeze
"Squeeze", input=input, squeeze_dims=axis, name=name)
File "c:\users\\envs\eva_env\lib\site-packages\tensorflow_core\python\framework\op_def_library.py", line 794, in _apply_op_helper
op_def=op_def)
File "c:\users\\envs\eva_env\lib\site-packages\tensorflow_core\python\util\deprecation.py", line 507, in new_func
return func(*args, **kwargs)
File "c:\users\\envs\eva_env\lib\site-packages\tensorflow_core\python\framework\ops.py", line 3357, in create_op
attrs, op_def, compute_device)
File "c:\users\\envs\eva_env\lib\site-packages\tensorflow_core\python\framework\ops.py", line 3426, in _create_op_internal
op_def=op_def)
File "c:\users\\envs\eva_env\lib\site-packages\tensorflow_core\python\framework\ops.py", line 1770, in __init__
control_input_ops)
File "c:\users\\envs\eva_env\lib\site-packages\tensorflow_core\python\framework\ops.py", line 1610, in _create_c_op
raise ValueError(str(e))
ValueError: Can not squeeze dim[1], expected a dimension of 1, got 2 for 'Squeeze_2' (op: 'Squeeze') with input shapes: [18,2,20].

# Fixed code
def _combine_sparse_dense_features(
    self,
    features: List[Union[tf.Tensor, tf.SparseTensor]],
    mask: tf.Tensor,
    name: Text,
) -> tf.Tensor:
    dense_features = []

    dense_dim = self.dense_dim[name]
    # if dense features are present use the feature dimension of the dense features
    for f in features:
        if not isinstance(f, tf.SparseTensor):
            dense_dim = f.shape[-1]
            break

    for f in features:
        if isinstance(f, tf.SparseTensor):
            dense_features.append(
                train_utils.tf_dense_layer_for_sparse(f, dense_dim, name, self.C2)
            )
        else:
            dense_features.append(f)

    output = tf.concat(dense_features, axis=-1) * mask
    # reduce dimensionality of output
    output = tf.reduce_sum(output, axis=1)

    return output