code: def tensor_to_df(
      tensor: torch.LongTensor,
      **kwargs: Union[torch.Tensor, np.ndarray, Sequence],
  ) -> pandas.DataFrame:
      """Take a tensor of triples and make a pandas dataframe with labels.
  
      :param tensor: shape: (n, 3)
          The triples, ID-based and in format (head_id, relation_id, tail_id).
      :param kwargs:
          Any additional number of columns. Each column needs to be of shape (n,). Reserved column names:
          {"head_id", "head_label", "relation_id", "relation_label", "tail_id", "tail_label"}.
  
      :return:
          A dataframe with n rows, and 3 + len(kwargs) columns.
  
      :raises ValueError:
          If a reserved column name appears in kwargs.
      """
      # Input validation
      additional_columns = set(kwargs.keys())
      forbidden = additional_columns.intersection(TRIPLES_DF_COLUMNS)
      if len(forbidden) > 0:
          raise ValueError(
              f"The key-words for additional arguments must not be in {TRIPLES_DF_COLUMNS}, but {forbidden} were "
              f"used.",
          )
  
      # convert to numpy
      tensor = tensor.cpu().numpy()
      data = dict(zip(["head_id", "relation_id", "tail_id"], tensor.T))
  
      # Additional columns
      for key, values in kwargs.items():
          # convert PyTorch tensors to numpy
          if isinstance(values, torch.Tensor):
              values = values.cpu().numpy()
          data[key] = values
  
      # convert to dataframe
      rv = pandas.DataFrame(data=data)
  
      # Re-order columns
      columns = list(TRIPLES_DF_COLUMNS[::2]) + sorted(
          set(rv.columns).difference(TRIPLES_DF_COLUMNS)
      )
      return rv.loc[:, columns]
  
file_path: pykeen/src/pykeen/triples/utils.py
imports: import pathlib
  from typing import Callable, List, Mapping, Optional, Sequence, Set, TextIO, Tuple, Union
  import numpy
  import pandas
  import torch
  from pkg_resources import iter_entry_points
  from ..typing import LabeledTriples, MappedTriples
label_desc: Use image node_id 5 for calling a global function with example usage: tensor_to_df(tensor) and returns: rv