Repository: deepset-ai/haystack

Issue:
Running training triggers many UserWarning: Creating a tensor from a list of numpy.ndarrays is extremely slow
**Describe the bug**
Running training using:
DensePassageRetriever.train(), triggers many UserWarning.

**Error message**
haystack/modeling/data_handler/dataset.py:65: UserWarning: Creating a tensor from a list of numpy.ndarrays is extremely slow. Please consider converting the list to a single numpy.ndarray with numpy.array() before converting to a tensor. (Triggered internally at  ../torch/csrc/utils/tensor_new.cpp:201.)

**Expected behavior**
No UserWarning

**To Reproduce**
```
document_store = FAISSDocumentStore.load(index_path=faiss_index_path, config_path=faiss_config_path)

retriever = DensePassageRetriever(document_store=document_store,
                                      query_embedding_model='bert-base-uncased',
                                      passage_embedding_model='bert-base-uncased',
                                      infer_tokenizer_classes=True,
                                      max_seq_len_query=64,
                                      max_seq_len_passage=180
                                      )

retriever.train(data_dir=doc_dir,
                    train_filename=train_filename,
                    dev_filename=dev_filename,
                    test_filename=dev_filename,
                    n_epochs=n_epochs,
                    batch_size=16,
                    grad_acc_steps=8,
                    save_dir=save_dir,
                    evaluate_every=20,
                    embed_title=False,
                    num_positives=1,
                    num_hard_negatives=1
                    )

**System:**
 - OS: 16.04.1-Ubuntu
 - GPU/CPU: TITAN Xp
 - Haystack version (commit or version number): v1.0.0
 - DocumentStore: FAISSDocumentStore
 - Reader: NA
 - Retriever: DensePassageRetriever

DPR training fails on multiple GPU's
**Describe the bug**
Following the DPR training [guide](https://haystack.deepset.ai/tutorials/train-dpr), in case trying to run on multiple GPU's, training will fail with a "AttributeError". Trying to call a `BiAdaptiveModel` method on a `DataParallel` object instance. 

**Error message**
AttributeError: 'DataParallel' object has no attribute 'connect_heads_with_processor'

**Expected behavior**
No error

**System:**
 - OS: Ubuntu
 - GPU/CPU: TITAN Xp
 - Haystack version (commit or version number): v0.10.0
 - DocumentStore: InMemoryDocumentStore
 - Reader: 'NA'
 - Retriever: DensePassageRetriever



Discussion:

Resolving patch:
diff --git a/haystack/modeling/data_handler/processor.py b/haystack/modeling/data_handler/processor.py
--- a/haystack/modeling/data_handler/processor.py
+++ b/haystack/modeling/data_handler/processor.py
@@ -1102,8 +1102,7 @@ def _convert_contexts(self, baskets: List[SampleBasket]):
                         return_token_type_ids=True
                     )
 
-                    # TODO check if we need this and potentially remove
-                    ctx_segment_ids = np.zeros_like(ctx_inputs["token_type_ids"], dtype=np.int32)
+                    ctx_segment_ids = [[0] * len(ctx_inputs["token_type_ids"][0])] * len(ctx_inputs["token_type_ids"])
 
                     # get tokens in string format
                     tokenized_passage = [self.passage_tokenizer.convert_ids_to_tokens(ctx) for ctx in ctx_inputs["input_ids"]]


Test patch: