code: def data_to_table(series, names, step):
      table = []
  
      for s in range(len(series)):
          data = series[s]
          name = names[s]
  
          try:
              import torch
          except ImportError:
              torch = None
  
          if torch is not None and isinstance(data, torch.Tensor):
              data = data.detach().cpu().numpy()
  
          for i in range(data.shape[0]):
              if len(data.shape) == 2:
                  m = data.shape[1] // 2
                  row = {
                      "series": name,
                      "step": data[i, 0],
                      "v5": data[i, m],
                  }
                  for j in range(1, min(m, 5)):
                      row[f"v{5 - j}"] = data[i, m - j]
                      row[f"v{5 + j}"] = data[i, m + j]
              elif step is not None:
                  row = {"series": name, "step": step[i], "v5": data[i]}
              else:
                  row = {"series": name, "step": i, "v5": data[i]}
              table.append(row)
  
      return alt.Data(values=table)
  
imports: from typing import List
  import altair
label_desc: Use image node_id 1 for calling a global function with example usage: data_to_table(series, names, step) and returns: alt