code: def cat_coo(
      tensors: List[Tensor], dim: Union[int, Tuple[int, int]]
  ) -> Tensor:
      assert dim in {0, 1, (0, 1)}
      assert tensors[0].layout == torch.sparse_coo
  
      indices, values = [], []
      num_rows = num_cols = 0
  
      if dim == 0:
          for i, tensor in enumerate(tensors):
              if i == 0:
                  indices.append(tensor.indices())
              else:
                  offset = torch.tensor(
                      [[num_rows], [0]], device=tensor.device
                  )
                  indices.append(tensor.indices() + offset)
              values.append(tensor.values())
              num_rows += tensor.size(0)
              num_cols = max(num_cols, tensor.size(1))
  
      elif dim == 1:
          for i, tensor in enumerate(tensors):
              if i == 0:
                  indices.append(tensor.indices())
              else:
                  offset = torch.tensor(
                      [[0], [num_cols]], device=tensor.device
                  )
                  indices.append(tensor.indices() + offset)
              values.append(tensor.values())
              num_rows = max(num_rows, tensor.size(0))
              num_cols += tensor.size(1)
  
      else:
          for i, tensor in enumerate(tensors):
              if i == 0:
                  indices.append(tensor.indices())
              else:
                  offset = torch.tensor(
                      [[num_rows], [num_cols]], device=tensor.device
                  )
                  indices.append(tensor.indices() + offset)
              values.append(tensor.values())
              num_rows += tensor.size(0)
              num_cols += tensor.size(1)
  
      return torch.sparse_coo_tensor(
          indices=torch.cat(indices, dim=-1),
          values=torch.cat(values),
          size=(num_rows, num_cols) + values[-1].size()[1:],
          device=tensor.device,
      )
  
imports: import typing
  import warnings
  from typing import Any, List, Optional, Tuple, Union
  import torch
  from torch import Tensor
  import torch_geometric.typing
  from torch_geometric.typing import SparseTensor
  from torch_geometric.utils import coalesce, cumsum
label_desc: Use image node_id 13 for calling a global function with example usage: cat_coo(tensors, dim) and returns: torch