Repository: Lightning-AI/pytorch-lightning

Issue:
UserWarning: Was asked to gather along dimension 0, but all input tensors were scalars
**Describe the bug**
Not sure if this is a bug. It shows me this warning at the beginning of training:
`
/home/adrian/research/envs/research/lib/python3.7/site-packages/torch/nn/parallel/_functions.py:61: UserWarning: Was asked to gather along dimension 0, but all input tensors were scalars; will instead unsqueeze and return a vector.
`

**To Reproduce**
The minimal MNIST example from the docs has this problem when trained on multiple GPUs. Attached the Python script:
```
import os
import torch
from torch.nn import functional as F
from torch.utils.data import DataLoader
from torchvision.datasets import MNIST
import torchvision.transforms as transforms

import pytorch_lightning as pl


class CoolModel(pl.LightningModule):

    def __init__(self):
        super(CoolModel, self).__init__()
        # not the best model...
        self.l1 = torch.nn.Linear(28 * 28, 10)

    def forward(self, x):
        return torch.relu(self.l1(x.view(x.size(0), -1)))

    def training_step(self, batch, batch_nb):
        # REQUIRED
        x, y = batch
        y_hat = self.forward(x)
        return {'loss': F.cross_entropy(y_hat, y)}

    def validation_step(self, batch, batch_nb):
        # OPTIONAL
        x, y = batch
        y_hat = self.forward(x)
        return {'val_loss': F.cross_entropy(y_hat, y)}

    def validation_end(self, outputs):
        # OPTIONAL
        avg_loss = torch.stack([x['val_loss'] for x in outputs]).mean()
        return {'avg_val_loss': avg_loss}

    def test_step(self, batch, batch_nb):
        # OPTIONAL
        x, y = batch
        y_hat = self.forward(x)
        return {'test_loss': F.cross_entropy(y_hat, y)}

    def test_end(self, outputs):
        # OPTIONAL
        avg_loss = torch.stack([x['test_loss'] for x in outputs]).mean()
        return {'avg_test_loss': avg_loss}

    def configure_optimizers(self):
        # REQUIRED
        return [torch.optim.Adam(self.parameters(), lr=0.02)]

    @pl.data_loader
    def tng_dataloader(self):
        return DataLoader(MNIST(os.getcwd(), train=True, download=True, transform=transforms.ToTensor()), batch_size=32)

    @pl.data_loader
    def val_dataloader(self):
        # OPTIONAL
        # can also return a list of val dataloaders
        return DataLoader(MNIST(os.getcwd(), train=True, download=True, transform=transforms.ToTensor()), batch_size=32)

    @pl.data_loader
    def test_dataloader(self):
        # OPTIONAL
        # can also return a list of test dataloaders
        return DataLoader(MNIST(os.getcwd(), train=False, download=True, transform=transforms.ToTensor()), batch_size=32)


if __name__ == '__main__':
    from pytorch_lightning import Trainer

    trainer = Trainer(
        gpus=[2, 3],
        distributed_backend='dp',
    )

    model = CoolModel()
    trainer.fit(model)


```


**Expected behavior**
There are no scalars involved in the forward pass, so the warning does not make sense and should not be shown.

**Desktop (please complete the following information):**
 - OS: Ubuntu 18.04
 - Version: the latest pip install


Discussion:

Resolving patch:
diff --git a/pytorch_lightning/trainer/ignored_warnings.py b/pytorch_lightning/trainer/ignored_warnings.py
new file mode 100644
--- /dev/null
+++ b/pytorch_lightning/trainer/ignored_warnings.py
@@ -0,0 +1,14 @@
+import warnings
+
+
+def ignore_scalar_return_in_dp():
+    # Users get confused by this warning so we silence it
+    m_1 = """
+    Was asked to gather along dimension 0, but all
+    input tensors were scalars; will instead unsqueeze
+    and return a vector.
+    """
+    warnings.filterwarnings('ignore', message=m_1)
+
+
+ignore_scalar_return_in_dp()
diff --git a/pytorch_lightning/trainer/trainer.py b/pytorch_lightning/trainer/trainer.py
--- a/pytorch_lightning/trainer/trainer.py
+++ b/pytorch_lightning/trainer/trainer.py
@@ -22,6 +22,7 @@
 from pytorch_lightning.callbacks import GradientAccumulationScheduler
 from pytorch_lightning.utilities.debugging import MisconfigurationException
 import pdb
+from pytorch_lightning.trainer import ignored_warnings
 
 try:
     from apex import amp


Test patch: