code: def index_select(
      value: FeatureTensorType,
      index: Tensor,
      dim: int = 0,
  ) -> Tensor:
      r"""Indexes the :obj:`value` tensor along dimension :obj:`dim` using the
      entries in :obj:`index`.
  
      Args:
          value (torch.Tensor or np.ndarray): The input tensor.
          index (torch.Tensor): The 1-D tensor containing the indices to index.
          dim (int, optional): The dimension in which to index.
              (default: :obj:`0`)
  
      .. warning::
  
          :obj:`index` is casted to a :obj:`torch.int64` tensor internally, as
          `PyTorch currently only supports indexing
          <https://github.com/pytorch/pytorch/issues/61819>`_ via
          :obj:`torch.int64`.
      """
      # PyTorch currently only supports indexing via `torch.int64`:
      # https://github.com/pytorch/pytorch/issues/61819
      index = index.to(torch.int64)
  
      if isinstance(value, Tensor):
          out: Optional[Tensor] = None
          if torch.utils.data.get_worker_info() is not None:
              # If we are in a background process, we write directly into a
              # shared memory tensor to avoid an extra copy:
              size = list(value.shape)
              size[dim] = index.numel()
              numel = math.prod(size)
              if torch_geometric.typing.WITH_PT20:
                  storage = value.untyped_storage()._new_shared(
                      numel * value.element_size()
                  )
              else:
                  storage = value.storage()._new_shared(numel)
              out = value.new(storage).view(size)
  
          return torch.index_select(value, dim, index, out=out)
  
      if isinstance(value, TensorFrame):
          assert dim == 0
          return value[index]
  
      elif isinstance(value, np.ndarray):
          return torch.from_numpy(np.take(value, index, axis=dim))
  
      raise ValueError(
          f"Encountered invalid feature tensor type "
          f"(got '{type(value)}')"
      )
  
imports: import copy
  import logging
  import math
  from typing import Any, Dict, Optional, Tuple, Union
  import numpy
  import torch
  from torch import Tensor
  import torch_geometric.typing
  from torch_geometric import EdgeIndex
  from torch_geometric.data import Data, FeatureStore, GraphStore, HeteroData, TensorAttr, remote_backend_utils
  from torch_geometric.data.storage import EdgeStorage, NodeStorage
  from torch_geometric.typing import EdgeType, FeatureTensorType, InputEdges, InputNodes, NodeType, OptTensor, SparseTensor, TensorFrame
label_desc: Use image node_id 1 for calling a global function with example usage: index_select(value, index, dim) and returns: torch, value, torch