We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
RuntimeError: Unimplemented backend XLA on TPU
## 🐛 Bug

`RuntimeError: Unimplemented backend XLA` raised for `self.batch_loss_value.append(loss)` line in `trainer/training_loop.py` file when running MNIST on TPU. I think it was introduced in 31b7148.

### To Reproduce

Steps to reproduce the behavior:

1. Go to [MNIST on TPUs](https://colab.research.google.com/drive/1-_LKx4HwAxl5M6xPJmqAAu444LTDQoa3)
2. Run all
3. Scroll down to trainer
4. See error

```
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/torch_xla/distributed/xla_multiprocessing.py", line 119, in _start_fn
    fn(gindex, *args)
  File "/usr/local/lib/python3.6/dist-packages/torch_xla/distributed/xla_multiprocessing.py", line 119, in _start_fn
    fn(gindex, *args)
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/distrib_parts.py", line 499, in tpu_train
    self.run_pretrain_routine(model)
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/distrib_parts.py", line 499, in tpu_train
    self.run_pretrain_routine(model)
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/distrib_parts.py", line 499, in tpu_train
    self.run_pretrain_routine(model)
  File "/usr/local/lib/python3.6/dist-packages/torch_xla/distributed/xla_multiprocessing.py", line 119, in _start_fn
    fn(gindex, *args)
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/distrib_parts.py", line 499, in tpu_train
    self.run_pretrain_routine(model)
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/distrib_parts.py", line 499, in tpu_train
    self.run_pretrain_routine(model)
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/distrib_parts.py", line 499, in tpu_train
    self.run_pretrain_routine(model)
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/trainer.py", line 920, in run_pretrain_routine
    self.train()
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/trainer.py", line 920, in run_pretrain_routine
    self.train()
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/trainer.py", line 920, in run_pretrain_routine
    self.train()
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/trainer.py", line 920, in run_pretrain_routine
    self.train()
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/trainer.py", line 920, in run_pretrain_routine
    self.train()
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/trainer.py", line 920, in run_pretrain_routine
    self.train()
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py", line 356, in train
    self.run_training_epoch()
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py", line 356, in train
    self.run_training_epoch()
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/distrib_parts.py", line 499, in tpu_train
    self.run_pretrain_routine(model)
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py", line 356, in train
    self.run_training_epoch()
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py", line 356, in train
    self.run_training_epoch()
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py", line 356, in train
    self.run_training_epoch()
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py", line 356, in train
    self.run_training_epoch()
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py", line 425, in run_training_epoch
    output = self.run_training_batch(batch, batch_idx)
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py", line 425, in run_training_epoch
    output = self.run_training_batch(batch, batch_idx)
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/trainer.py", line 920, in run_pretrain_routine
    self.train()
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py", line 425, in run_training_epoch
    output = self.run_training_batch(batch, batch_idx)
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py", line 425, in run_training_epoch
    output = self.run_training_batch(batch, batch_idx)
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py", line 425, in run_training_epoch
    output = self.run_training_batch(batch, batch_idx)
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py", line 425, in run_training_epoch
    output = self.run_training_batch(batch, batch_idx)
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py", line 582, in run_training_batch
    self.batch_loss_value.append(loss)
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py", line 582, in run_training_batch
    self.batch_loss_value.append(loss)
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/supporting_classes.py", line 23, in append
    if self.memory.type() != x.type():
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py", line 356, in train
    self.run_training_epoch()
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py", line 582, in run_training_batch
    self.batch_loss_value.append(loss)
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py", line 582, in run_training_batch
    self.batch_loss_value.append(loss)
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py", line 582, in run_training_batch
    self.batch_loss_value.append(loss)
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/supporting_classes.py", line 23, in append
    if self.memory.type() != x.type():
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py", line 582, in run_training_batch
    self.batch_loss_value.append(loss)
Exception in device=TPU:5: Unimplemented backend XLA
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/supporting_classes.py", line 23, in append
    if self.memory.type() != x.type():
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py", line 425, in run_training_epoch
    output = self.run_training_batch(batch, batch_idx)
RuntimeError: Unimplemented backend XLA
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/supporting_classes.py", line 23, in append
    if self.memory.type() != x.type():
RuntimeError: Unimplemented backend XLA
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/supporting_classes.py", line 23, in append
    if self.memory.type() != x.type():
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/supporting_classes.py", line 23, in append
    if self.memory.type() != x.type():
RuntimeError: Unimplemented backend XLA
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py", line 582, in run_training_batch
    self.batch_loss_value.append(loss)
RuntimeError: Unimplemented backend XLA
Traceback (most recent call last):
RuntimeError: Unimplemented backend XLA
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/supporting_classes.py", line 23, in append
    if self.memory.type() != x.type():
RuntimeError: Unimplemented backend XLA
  File "/usr/local/lib/python3.6/dist-packages/torch_xla/distributed/xla_multiprocessing.py", line 119, in _start_fn
    fn(gindex, *args)
RuntimeError: Unimplemented backend XLA
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/distrib_parts.py", line 499, in tpu_train
    self.run_pretrain_routine(model)
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/trainer.py", line 920, in run_pretrain_routine
    self.train()
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py", line 356, in train
    self.run_training_epoch()
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py", line 425, in run_training_epoch
    output = self.run_training_batch(batch, batch_idx)
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py", line 582, in run_training_batch
    self.batch_loss_value.append(loss)
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/supporting_classes.py", line 23, in append
    if self.memory.type() != x.type():
RuntimeError: Unimplemented backend XLA
---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
<ipython-input-2-12f6e300d51d> in <module>()
      6 # most basic trainer, uses good defaults
      7 trainer = Trainer(num_tpu_cores=8)
----> 8 trainer.fit(model)

3 frames
/usr/local/lib/python3.6/dist-packages/torch/multiprocessing/spawn.py in join(self, timeout)
    111                 raise Exception(
    112                     "process %d terminated with exit code %d" %
--> 113                     (error_index, exitcode)
    114                 )
    115 

Exception: process 4 terminated with exit code 17
```

### Environment

 - PyTorch Version (e.g., 1.0): 1.6
 - OS (e.g., Linux): Linux
 - How you installed PyTorch (`conda`, `pip`, source): pip
 - Build command you used (if compiling from source): -
 - Python version: 3.6
 - CUDA/cuDNN version: -
 - GPU models and configuration: -
 - Any other relevant information: TPU backend


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `pytorch_lightning/trainer/supporters.py`
Content:
```
1 import torch
2 
3 
4 class TensorRunningMean(object):
5     """
6     Tracks a running mean without graph references.
7     Round robbin for the mean
8 
9     Examples:
10         >>> accum = TensorRunningMean(5)
11         >>> accum.last(), accum.mean()
12         (None, None)
13         >>> accum.append(torch.tensor(1.5))
14         >>> accum.last(), accum.mean()
15         (tensor(1.5000), tensor(1.5000))
16         >>> accum.append(torch.tensor(2.5))
17         >>> accum.last(), accum.mean()
18         (tensor(2.5000), tensor(2.))
19         >>> accum.reset()
20         >>> _= [accum.append(torch.tensor(i)) for i in range(13)]
21         >>> accum.last(), accum.mean()
22         (tensor(12.), tensor(10.))
23     """
24     def __init__(self, window_length: int):
25         self.window_length = window_length
26         self.memory = torch.Tensor(self.window_length)
27         self.current_idx: int = 0
28         self.last_idx: int = None
29         self.rotated: bool = False
30 
31     def reset(self) -> None:
32         self = TensorRunningMean(self.window_length)
33 
34     def last(self):
35         if self.last_idx is not None:
36             return self.memory[self.last_idx]
37 
38     def append(self, x):
39         # map proper type for memory if they don't match
40         if self.memory.type() != x.type():
41             self.memory.type_as(x)
42 
43         # store without grads
44         with torch.no_grad():
45             self.memory[self.current_idx] = x
46             self.last_idx = self.current_idx
47 
48         # increase index
49         self.current_idx += 1
50 
51         # reset index when hit limit of tensor
52         self.current_idx = self.current_idx % self.window_length
53         if self.current_idx == 0:
54             self.rotated = True
55 
56     def mean(self):
57         if self.last_idx is not None:
58             return self.memory.mean() if self.rotated else self.memory[:self.current_idx].mean()
59
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/pytorch_lightning/trainer/supporters.py b/pytorch_lightning/trainer/supporters.py
--- a/pytorch_lightning/trainer/supporters.py
+++ b/pytorch_lightning/trainer/supporters.py
@@ -36,9 +36,9 @@
             return self.memory[self.last_idx]
 
     def append(self, x):
-        # map proper type for memory if they don't match
-        if self.memory.type() != x.type():
-            self.memory.type_as(x)
+        # ensure same device and type
+        if self.memory.device != x.device or self.memory.type() != x.type():
+            x = x.to(self.memory)
 
         # store without grads
         with torch.no_grad():

{"golden_diff": "diff --git a/pytorch_lightning/trainer/supporters.py b/pytorch_lightning/trainer/supporters.py\n--- a/pytorch_lightning/trainer/supporters.py\n+++ b/pytorch_lightning/trainer/supporters.py\n@@ -36,9 +36,9 @@\n             return self.memory[self.last_idx]\n \n     def append(self, x):\n-        # map proper type for memory if they don't match\n-        if self.memory.type() != x.type():\n-            self.memory.type_as(x)\n+        # ensure same device and type\n+        if self.memory.device != x.device or self.memory.type() != x.type():\n+            x = x.to(self.memory)\n \n         # store without grads\n         with torch.no_grad():\n", "issue": "RuntimeError: Unimplemented backend XLA on TPU\n## \ud83d\udc1b Bug\r\n\r\n`RuntimeError: Unimplemented backend XLA` raised for `self.batch_loss_value.append(loss)` line in `trainer/training_loop.py` file when running MNIST on TPU. I think it was introduced in 31b7148.\r\n\r\n### To Reproduce\r\n\r\nSteps to reproduce the behavior:\r\n\r\n1. Go to [MNIST on TPUs](https://colab.research.google.com/drive/1-_LKx4HwAxl5M6xPJmqAAu444LTDQoa3)\r\n2. Run all\r\n3. Scroll down to trainer\r\n4. See error\r\n\r\n```\r\nTraceback (most recent call last):\r\n  File \"/usr/local/lib/python3.6/dist-packages/torch_xla/distributed/xla_multiprocessing.py\", line 119, in _start_fn\r\n    fn(gindex, *args)\r\n  File \"/usr/local/lib/python3.6/dist-packages/torch_xla/distributed/xla_multiprocessing.py\", line 119, in _start_fn\r\n    fn(gindex, *args)\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/distrib_parts.py\", line 499, in tpu_train\r\n    self.run_pretrain_routine(model)\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/distrib_parts.py\", line 499, in tpu_train\r\n    self.run_pretrain_routine(model)\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/distrib_parts.py\", line 499, in tpu_train\r\n    self.run_pretrain_routine(model)\r\n  File \"/usr/local/lib/python3.6/dist-packages/torch_xla/distributed/xla_multiprocessing.py\", line 119, in _start_fn\r\n    fn(gindex, *args)\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/distrib_parts.py\", line 499, in tpu_train\r\n    self.run_pretrain_routine(model)\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/distrib_parts.py\", line 499, in tpu_train\r\n    self.run_pretrain_routine(model)\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/distrib_parts.py\", line 499, in tpu_train\r\n    self.run_pretrain_routine(model)\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/trainer.py\", line 920, in run_pretrain_routine\r\n    self.train()\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/trainer.py\", line 920, in run_pretrain_routine\r\n    self.train()\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/trainer.py\", line 920, in run_pretrain_routine\r\n    self.train()\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/trainer.py\", line 920, in run_pretrain_routine\r\n    self.train()\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/trainer.py\", line 920, in run_pretrain_routine\r\n    self.train()\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/trainer.py\", line 920, in run_pretrain_routine\r\n    self.train()\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py\", line 356, in train\r\n    self.run_training_epoch()\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py\", line 356, in train\r\n    self.run_training_epoch()\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/distrib_parts.py\", line 499, in tpu_train\r\n    self.run_pretrain_routine(model)\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py\", line 356, in train\r\n    self.run_training_epoch()\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py\", line 356, in train\r\n    self.run_training_epoch()\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py\", line 356, in train\r\n    self.run_training_epoch()\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py\", line 356, in train\r\n    self.run_training_epoch()\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py\", line 425, in run_training_epoch\r\n    output = self.run_training_batch(batch, batch_idx)\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py\", line 425, in run_training_epoch\r\n    output = self.run_training_batch(batch, batch_idx)\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/trainer.py\", line 920, in run_pretrain_routine\r\n    self.train()\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py\", line 425, in run_training_epoch\r\n    output = self.run_training_batch(batch, batch_idx)\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py\", line 425, in run_training_epoch\r\n    output = self.run_training_batch(batch, batch_idx)\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py\", line 425, in run_training_epoch\r\n    output = self.run_training_batch(batch, batch_idx)\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py\", line 425, in run_training_epoch\r\n    output = self.run_training_batch(batch, batch_idx)\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py\", line 582, in run_training_batch\r\n    self.batch_loss_value.append(loss)\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py\", line 582, in run_training_batch\r\n    self.batch_loss_value.append(loss)\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/supporting_classes.py\", line 23, in append\r\n    if self.memory.type() != x.type():\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py\", line 356, in train\r\n    self.run_training_epoch()\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py\", line 582, in run_training_batch\r\n    self.batch_loss_value.append(loss)\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py\", line 582, in run_training_batch\r\n    self.batch_loss_value.append(loss)\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py\", line 582, in run_training_batch\r\n    self.batch_loss_value.append(loss)\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/supporting_classes.py\", line 23, in append\r\n    if self.memory.type() != x.type():\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py\", line 582, in run_training_batch\r\n    self.batch_loss_value.append(loss)\r\nException in device=TPU:5: Unimplemented backend XLA\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/supporting_classes.py\", line 23, in append\r\n    if self.memory.type() != x.type():\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py\", line 425, in run_training_epoch\r\n    output = self.run_training_batch(batch, batch_idx)\r\nRuntimeError: Unimplemented backend XLA\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/supporting_classes.py\", line 23, in append\r\n    if self.memory.type() != x.type():\r\nRuntimeError: Unimplemented backend XLA\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/supporting_classes.py\", line 23, in append\r\n    if self.memory.type() != x.type():\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/supporting_classes.py\", line 23, in append\r\n    if self.memory.type() != x.type():\r\nRuntimeError: Unimplemented backend XLA\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py\", line 582, in run_training_batch\r\n    self.batch_loss_value.append(loss)\r\nRuntimeError: Unimplemented backend XLA\r\nTraceback (most recent call last):\r\nRuntimeError: Unimplemented backend XLA\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/supporting_classes.py\", line 23, in append\r\n    if self.memory.type() != x.type():\r\nRuntimeError: Unimplemented backend XLA\r\n  File \"/usr/local/lib/python3.6/dist-packages/torch_xla/distributed/xla_multiprocessing.py\", line 119, in _start_fn\r\n    fn(gindex, *args)\r\nRuntimeError: Unimplemented backend XLA\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/distrib_parts.py\", line 499, in tpu_train\r\n    self.run_pretrain_routine(model)\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/trainer.py\", line 920, in run_pretrain_routine\r\n    self.train()\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py\", line 356, in train\r\n    self.run_training_epoch()\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py\", line 425, in run_training_epoch\r\n    output = self.run_training_batch(batch, batch_idx)\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/training_loop.py\", line 582, in run_training_batch\r\n    self.batch_loss_value.append(loss)\r\n  File \"/usr/local/lib/python3.6/dist-packages/pytorch_lightning/trainer/supporting_classes.py\", line 23, in append\r\n    if self.memory.type() != x.type():\r\nRuntimeError: Unimplemented backend XLA\r\n---------------------------------------------------------------------------\r\nException                                 Traceback (most recent call last)\r\n<ipython-input-2-12f6e300d51d> in <module>()\r\n      6 # most basic trainer, uses good defaults\r\n      7 trainer = Trainer(num_tpu_cores=8)\r\n----> 8 trainer.fit(model)\r\n\r\n3 frames\r\n/usr/local/lib/python3.6/dist-packages/torch/multiprocessing/spawn.py in join(self, timeout)\r\n    111                 raise Exception(\r\n    112                     \"process %d terminated with exit code %d\" %\r\n--> 113                     (error_index, exitcode)\r\n    114                 )\r\n    115 \r\n\r\nException: process 4 terminated with exit code 17\r\n```\r\n\r\n### Environment\r\n\r\n - PyTorch Version (e.g., 1.0): 1.6\r\n - OS (e.g., Linux): Linux\r\n - How you installed PyTorch (`conda`, `pip`, source): pip\r\n - Build command you used (if compiling from source): -\r\n - Python version: 3.6\r\n - CUDA/cuDNN version: -\r\n - GPU models and configuration: -\r\n - Any other relevant information: TPU backend\r\n\n", "before_files": [{"content": "import torch\n\n\nclass TensorRunningMean(object):\n    \"\"\"\n    Tracks a running mean without graph references.\n    Round robbin for the mean\n\n    Examples:\n        >>> accum = TensorRunningMean(5)\n        >>> accum.last(), accum.mean()\n        (None, None)\n        >>> accum.append(torch.tensor(1.5))\n        >>> accum.last(), accum.mean()\n        (tensor(1.5000), tensor(1.5000))\n        >>> accum.append(torch.tensor(2.5))\n        >>> accum.last(), accum.mean()\n        (tensor(2.5000), tensor(2.))\n        >>> accum.reset()\n        >>> _= [accum.append(torch.tensor(i)) for i in range(13)]\n        >>> accum.last(), accum.mean()\n        (tensor(12.), tensor(10.))\n    \"\"\"\n    def __init__(self, window_length: int):\n        self.window_length = window_length\n        self.memory = torch.Tensor(self.window_length)\n        self.current_idx: int = 0\n        self.last_idx: int = None\n        self.rotated: bool = False\n\n    def reset(self) -> None:\n        self = TensorRunningMean(self.window_length)\n\n    def last(self):\n        if self.last_idx is not None:\n            return self.memory[self.last_idx]\n\n    def append(self, x):\n        # map proper type for memory if they don't match\n        if self.memory.type() != x.type():\n            self.memory.type_as(x)\n\n        # store without grads\n        with torch.no_grad():\n            self.memory[self.current_idx] = x\n            self.last_idx = self.current_idx\n\n        # increase index\n        self.current_idx += 1\n\n        # reset index when hit limit of tensor\n        self.current_idx = self.current_idx % self.window_length\n        if self.current_idx == 0:\n            self.rotated = True\n\n    def mean(self):\n        if self.last_idx is not None:\n            return self.memory.mean() if self.rotated else self.memory[:self.current_idx].mean()\n", "path": "pytorch_lightning/trainer/supporters.py"}], "after_files": [{"content": "import torch\n\n\nclass TensorRunningMean(object):\n    \"\"\"\n    Tracks a running mean without graph references.\n    Round robbin for the mean\n\n    Examples:\n        >>> accum = TensorRunningMean(5)\n        >>> accum.last(), accum.mean()\n        (None, None)\n        >>> accum.append(torch.tensor(1.5))\n        >>> accum.last(), accum.mean()\n        (tensor(1.5000), tensor(1.5000))\n        >>> accum.append(torch.tensor(2.5))\n        >>> accum.last(), accum.mean()\n        (tensor(2.5000), tensor(2.))\n        >>> accum.reset()\n        >>> _= [accum.append(torch.tensor(i)) for i in range(13)]\n        >>> accum.last(), accum.mean()\n        (tensor(12.), tensor(10.))\n    \"\"\"\n    def __init__(self, window_length: int):\n        self.window_length = window_length\n        self.memory = torch.Tensor(self.window_length)\n        self.current_idx: int = 0\n        self.last_idx: int = None\n        self.rotated: bool = False\n\n    def reset(self) -> None:\n        self = TensorRunningMean(self.window_length)\n\n    def last(self):\n        if self.last_idx is not None:\n            return self.memory[self.last_idx]\n\n    def append(self, x):\n        # ensure same device and type\n        if self.memory.device != x.device or self.memory.type() != x.type():\n            x = x.to(self.memory)\n\n        # store without grads\n        with torch.no_grad():\n            self.memory[self.current_idx] = x\n            self.last_idx = self.current_idx\n\n        # increase index\n        self.current_idx += 1\n\n        # reset index when hit limit of tensor\n        self.current_idx = self.current_idx % self.window_length\n        if self.current_idx == 0:\n            self.rotated = True\n\n    def mean(self):\n        if self.last_idx is not None:\n            return self.memory.mean() if self.rotated else self.memory[:self.current_idx].mean()\n", "path": "pytorch_lightning/trainer/supporters.py"}]}