code: def _convolve2d(in1, in2, use_convolve, mode, boundary, fillvalue):
      val = _valfrommode(mode)
      bval = _bvalfromboundary(boundary)
  
      # Promote inputs
      promType = cp.promote_types(in1.dtype, in2.dtype)
      in1 = in1.astype(promType)
      in2 = in2.astype(promType)
  
      if (bval != PAD) and (bval != REFLECT) and (bval != CIRCULAR):
          raise Exception("Incorrect boundary value.")
  
      if (bval == PAD) and (fillvalue is not None):
          fill = np.array(fillvalue, in1.dtype)
          if fill is None:
              raise Exception("fill must no be None.")
          if fill.size != 1:
              if fill.size == 0:
                  raise Exception(
                      "`fillvalue` cannot be an empty array."
                  )
              raise Exception(
                  "`fillvalue` must be scalar or an array with one element"
              )
      else:
          fill = np.zeros(1, in1.dtype)
          if fill is None:
              raise Exception("Unable to create fill array")
  
      # Create empty array to hold number of aout dimensions
      out_dimens = np.empty(in1.ndim, int)
      if val == VALID:
          for i in range(in1.ndim):
              out_dimens[i] = in1.shape[i] - in2.shape[i] + 1
              if out_dimens[i] < 0:
                  raise Exception(
                      "no part of the output is valid, use option 1 (same) or 2 \
                       (full) for third argument"
                  )
      elif val == SAME:
          for i in range(in1.ndim):
              out_dimens[i] = in1.shape[i]
      elif val == FULL:
          for i in range(in1.ndim):
              out_dimens[i] = in1.shape[i] + in2.shape[i] - 1
      else:
          raise Exception(
              "mode must be 0 (valid), 1 (same), or 2 (full)"
          )
  
      # Create empty array out on GPU
      out = cp.empty(out_dimens.tolist(), in1.dtype)
  
      out = _convolve2d_gpu(
          in1,
          out,
          in2,
          val,
          bval,
          use_convolve,
          fill,
      )
  
      return out
  
imports: import cupy
  import numpy
  from ..utils._caches import _cupy_kernel_cache
  from ..utils.helper_tools import _get_function, _get_tpb_bpg, _print_atts
  from .convolution_utils import CIRCULAR, FULL, PAD, REFLECT, SAME, VALID, _bvalfromboundary, _iDivUp, _valfrommode
label_desc: Use image node_id 6 for calling a global function with example usage: _convolve2d(in1, in2, use_convolve, mode, boundary, fillvalue) and returns: out