code: def __init__(self, mode):
      if mode == "grid":
          self._desc = "Compute the thread index in the grid."
          self._eq = "jit.threadIdx.x + jit.blockIdx.x * jit.blockDim.x"
          self._link = "numba.cuda.grid"
          self._code = "threadIdx.{n} + blockIdx.{n} * blockDim.{n}"
      elif mode == "gridsize":
          self._desc = "Compute the grid size."
          self._eq = "jit.blockDim.x * jit.gridDim.x"
          self._link = "numba.cuda.gridsize"
          self._code = "blockDim.{n} * gridDim.{n}"
      else:
          raise ValueError("unsupported function")
  
      doc = f"""        {self._desc}
  
          Computation of the first integer is as follows::
  
              {self._eq}
  
          and for the other two integers the ``y`` and ``z`` attributes are used.
  
          Args:
              ndim (int): The dimension of the grid. Only 1, 2, or 3 is allowed.
  
          Returns:
              int or tuple:
                  If ``ndim`` is 1, an integer is returned, otherwise a tuple.
  
          .. note::
              This function follows the convention of Numba's
              :func:`{self._link}`.
          """
      self.__doc__ = doc
  
imports: from typing import Any, Mapping
  import warnings
  import cupy
  from cupy_backends.cuda.api import runtime
  from cupy.cuda import device
  from cupyx.jit import _cuda_types
  from cupyx.jit import _cuda_typerules
  from cupyx.jit._internal_types import BuiltinFunc
  from cupyx.jit._internal_types import Data
  from cupyx.jit._internal_types import Constant
  from cupyx.jit._internal_types import Range
  from cupyx.jit import _compile
  from functools import reduce
label_desc: Use image node_id 1 to create a new GridFunc object from inherited base classes: BuiltinFunc with example: obj = GridFunc(mode)