code: def ptr2index(
      ptr: Tensor, output_size: Optional[int] = None
  ) -> Tensor:
      index = torch.arange(
          ptr.numel() - 1, dtype=ptr.dtype, device=ptr.device
      )
      return index.repeat_interleave(
          ptr.diff(), output_size=output_size
      )
  
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 11 for calling a global function with example usage: ptr2index(ptr, output_size) and returns: index