code: def cat(tensors, dim):  # noqa: F811
      assert len(tensors) > 0
  
      if isinstance(dim, int):
          dim = tensors[0].dim() + dim if dim < 0 else dim
  
          if dim == 0:
              return cat_first(tensors)
  
          elif dim == 1:
              return cat_second(tensors)
              pass
  
          elif dim > 1 and dim < tensors[0].dim():
              values = []
              for tensor in tensors:
                  value = tensor.storage.value()
                  assert value is not None
                  values.append(value)
              value = torch.cat(values, dim=dim - 1)
              return tensors[0].set_value(value, layout="coo")
  
          else:
              raise IndexError(
                  (
                      f"Dimension out of range: Expected to be in range of "
                      f"[{-tensors[0].dim()}, {tensors[0].dim() - 1}], but got "
                      f"{dim}."
                  )
              )
      else:
          assert isinstance(dim, (tuple, list))
          assert len(dim) == 2
          assert sorted(dim) == [0, 1]
          return cat_diag(tensors)
  
file_path: pytorch_sparse/torch_sparse/cat.py
imports: from typing import Optional, List, Tuple
  import torch
  from torch_sparse.storage import SparseStorage
  from torch_sparse.tensor import SparseTensor
label_desc: Use image node_id 4 for calling a global function with example usage: cat(tensors, dim) and returns: cat_diag, cat_first, cat_second, tensors