code: def _indexing(
      array: _internal_types.Expr,
      index: _internal_types.Expr,
      env: Environment,
  ) -> Union[Data, Constant]:
      if isinstance(array, Constant):
          if isinstance(index, Constant):
              return Constant(array.obj[index.obj])
          raise TypeError(
              f"{type(array.obj)} is not subscriptable with non-constants."
          )
  
      array = Data.init(array, env)
  
      if isinstance(array.ctype, _cuda_types.Tuple):
          if isinstance(index, Constant):
              i = index.obj
              t = array.ctype.types[i]
              # STD is defined in carray.cuh
              return Data(f"STD::get<{i}>({array.code})", t)
          raise TypeError(
              "Tuple is not subscriptable with non-constants."
          )
  
      if isinstance(array.ctype, _cuda_types.ArrayBase):
          index = Data.init(index, env)
          ndim = array.ctype._ndim
          if isinstance(index.ctype, _cuda_types.Scalar):
              index_dtype = index.ctype.dtype
              if ndim == 0:
                  raise TypeError(
                      "Scalar indexing is not supported for 0-dim array."
                  )
              if ndim > 1:
                  new_carray = _cuda_types.CArray(
                      array.ctype.dtype,
                      array.ctype._ndim - 1,
                      array.ctype._c_contiguous,
                      array.ctype._index_32_bits,
                  )
                  return Data(
                      f"{array.code}._slicing({index.code})", new_carray
                  )
              if index_dtype.kind not in "ui":
                  raise TypeError("Array indices must be integers.")
              return Data(
                  f"{array.code}[{index.code}]", array.ctype.child_type
              )
          if isinstance(index.ctype, _cuda_types.Tuple):
              if ndim < len(index.ctype.types):
                  raise IndexError(
                      f"The number of indices is beyond array dim: {ndim}"
                  )
              for t in index.ctype.types:
                  if not isinstance(t, _cuda_types.Scalar):
                      raise TypeError("Array indices must be scalar.")
                  if t.dtype.kind not in "iu":
                      raise TypeError("Array indices must be integer.")
              if ndim > len(index.ctype.types):
                  new_carray = _cuda_types.CArray(
                      array.ctype.dtype,
                      array.ctype._ndim - len(index.ctype.types),
                      array.ctype._c_contiguous,
                      array.ctype._index_32_bits,
                  )
                  params = (
                      f"{index.code}, Dim<{len(index.ctype.types)}>()"
                  )
                  return Data(
                      f"{array.code}._slicing({params})", new_carray
                  )
              if ndim == 0:
                  return Data(
                      f"{array.code}[0]", array.ctype.child_type
                  )
              if ndim == 1:
                  # STD is defined in carray.cuh
                  return Data(
                      f"{array.code}[STD::get<0>({index.code})]",
                      array.ctype.child_type,
                  )
              return Data(
                  f"{array.code}._indexing({index.code})",
                  array.ctype.child_type,
              )
          if isinstance(index.ctype, _cuda_types.CArray):
              raise TypeError("Advanced indexing is not supported.")
          assert False  # Never reach.
  
      raise TypeError(f"{array.code} is not subscriptable.")
  
imports: import ast
  import collections
  import inspect
  import linecache
  import numbers
  import re
  import sys
  from typing import Any, Dict, List, Optional, Sequence, Tuple, TypeVar, Union
  import warnings
  import types
  import numpy
  from cupy_backends.cuda.api import runtime
  from cupy._core._codeblock import CodeBlock, _CodeType
  from cupy._core import _kernel
  from cupy._core._dtype import _raise_if_invalid_cast
  from cupyx import jit
  from cupyx.jit import _cuda_types
  from cupyx.jit import _cuda_typerules
  from cupyx.jit import _internal_types
  from cupyx.jit._internal_types import Data
  from cupyx.jit._internal_types import Constant
  from cupyx.jit import _builtin_funcs
  from cupyx.jit import _interface
label_desc: Use image node_id 17 for calling a global function with example usage: _indexing(array, index, env) and returns: Constant, Data, Data, Data, Data, Data, Data, Data