# Buggy code
def reduce_across_time(cls, time_outputs):
    # auto-reduce across time for tbptt
    meta = time_outputs[0]["meta"]

    # in 1.0 the results have 'extra'. Once we deprecate 0.10.0 we may not need this
    if "extra" in time_outputs[0]:
        [x.pop("extra", None) for x in time_outputs]

    result = cls()
    result = recursive_gather(time_outputs, result)
    recursive_stack(result)

    for k, value in result.items():
        if k in ["meta", "extra"] or isinstance(value, Metric):
            continue

        # pick the reduce fx
        if k in ["checkpoint_on", "early_stop_on", "minimize"]:
            tbptt_reduce_fx = torch.mean
        else:
            tbptt_reduce_fx = meta[k]["tbptt_reduce_fx"]

        if isinstance(value, dict):
            # TODO: recursive reduce:
            _recursive_fx_apply(value, tbptt_reduce_fx)
        else:
            result[k] = tbptt_reduce_fx(value.float())

    result["meta"] = meta
    return result


# Traceback (TypeError)
-- Process 1 terminated with the following error:
Traceback (most recent call last):
File "/opt/conda/lib/python3.6/site-packages/torch/multiprocessing/spawn.py", line 20, in _wrap
fn(i, *args)
File "/opt/conda/lib/python3.6/site-packages/pytorch_lightning/accelerators/ddp_spawn_backend.py", line 165, in ddp_train
results = self.trainer.run_pretrain_routine(model)
File "/opt/conda/lib/python3.6/site-packages/pytorch_lightning/trainer/trainer.py", line 1237, in run_pretrain_routine
self.train()
File "/opt/conda/lib/python3.6/site-packages/pytorch_lightning/trainer/training_loop.py", line 396, in train
self.run_training_epoch()
File "/opt/conda/lib/python3.6/site-packages/pytorch_lightning/trainer/training_loop.py", line 543, in run_training_epoch
self.run_training_epoch_end(epoch_output, checkpoint_accumulator, early_stopping_accumulator, num_optimizers)
File "/opt/conda/lib/python3.6/site-packages/pytorch_lightning/trainer/training_loop.py", line 672, in run_training_epoch_end
epoch_log_metrics, epoch_progress_bar_metrics = self.__auto_reduce_results_on_epoch_end(epoch_output)
File "/opt/conda/lib/python3.6/site-packages/pytorch_lightning/trainer/training_loop.py", line 696, in __auto_reduce_results_on_epoch_end
tbptt_outs = tbptt_outs[0].__class__.reduce_across_time(tbptt_outs)
File "/opt/conda/lib/python3.6/site-packages/pytorch_lightning/core/step_result.py", line 392, in reduce_across_time
result[k] = tbptt_reduce_fx(value)
TypeError: mean(): argument 'input' (position 1) must be Tensor, not list

# Fixed code
def reduce_across_time(cls, time_outputs):
    # auto-reduce across time for tbptt
    meta = time_outputs[0]["meta"]

    # in 1.0 the results have 'extra'. Once we deprecate 0.10.0 we may not need this
    if "extra" in time_outputs[0]:
        [x.pop("extra", None) for x in time_outputs]

    result = cls()
    result = recursive_gather(time_outputs, result)
    recursive_stack(result)

    for k, value in result.items():
        if k in ["meta", "extra"] or isinstance(value, Metric):
            continue

        # pick the reduce fx
        if k in ["checkpoint_on", "early_stop_on", "minimize"]:
            tbptt_reduce_fx = torch.mean
        else:
            tbptt_reduce_fx = meta[k]["tbptt_reduce_fx"]

        if isinstance(value, list):
            value = torch.tensor(value)

        if isinstance(value, dict):
            # TODO: recursive reduce:
            _recursive_fx_apply(value, tbptt_reduce_fx)
        else:
            result[k] = tbptt_reduce_fx(value.float())

    result["meta"] = meta
    return result