code: def index2ptr(index: Tensor, size: Optional[int] = None) -> Tensor:
      if size is None:
          size = int(index.max()) + 1 if index.numel() > 0 else 0
  
      return torch._convert_indices_from_coo_to_csr(
          index, size, out_int32=index.dtype == torch.int32
      )
  
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 12 for calling a global function with example usage: index2ptr(index, size) and returns: torch