code: def _stack_preds(out):
      if isinstance(out[0], Sequence):
          out = [torch.stack(ts, dim=0) for ts in zip(*out)]
      else:
          out = torch.stack(out, dim=0)
      return out
  
file_path: baal/baal/transformers_trainer_wrapper.py
imports: from typing import Optional, List, Sequence, Union
  import numpy
  import structlog
  import torch
  from torch import nn
  from tqdm import tqdm
  from transformers import PreTrainedModel, TrainingArguments
  from baal.utils.warnings import raise_warnings_cache_replicated
  from baal.utils.array_utils import stack_in_memory
  from baal.utils.iterutils import map_on_tensor
label_desc: Use image node_id 1 for calling a global function with example usage: _stack_preds(out) and returns: out