code: def cross(a, b, axisa=-1, axisb=-1, axisc=-1, axis=None):
      """Returns the cross product of two vectors.
  
      The cross product of ``a`` and ``b`` in :math:`R^3` is a vector
      perpendicular to both ``a`` and ``b``.  If ``a`` and ``b`` are arrays
      of vectors, the vectors are defined by the last axis of ``a`` and ``b``
      by default, and these axes can have dimensions 2 or 3.  Where the
      dimension of either ``a`` or ``b`` is 2, the third component of the input
      vector is assumed to be zero and the cross product calculated accordingly.
      In cases where both input vectors have dimension 2, the z-component of
      the cross product is returned.
  
      Args:
          a (cupy.ndarray): Components of the first vector(s).
          b (cupy.ndarray): Components of the second vector(s).
          axisa (int, optional):
              Axis of ``a`` that defines the vector(s).
              By default, the last axis.
          axisb (int, optional):
              Axis of ``b`` that defines the vector(s).
              By default, the last axis.
          axisc (int, optional):
              Axis of ``c`` containing the cross product vector(s).  Ignored if
              both input vectors have dimension 2, as the return is scalar.
              By default, the last axis.
          axis (int, optional):
              If defined, the axis of ``a``, ``b`` and ``c``
              that defines the vector(s) and cross product(s).
              Overrides ``axisa``, ``axisb`` and ``axisc``.
  
      Returns:
          cupy.ndarray :
              Vector cross product(s).
  
      .. seealso:: :func:`numpy.cross`
  
      """
  
      if axis is not None:
          axisa, axisb, axisc = (axis,) * 3
      a = cupy.asarray(a)
      b = cupy.asarray(b)
      # Check axisa and axisb are within bounds
      axisa = internal._normalize_axis_index(axisa, a.ndim)
      axisb = internal._normalize_axis_index(axisb, b.ndim)
  
      # Move working axis to the end of the shape
      a = cupy.moveaxis(a, axisa, -1)
      b = cupy.moveaxis(b, axisb, -1)
      if a.shape[-1] not in (2, 3) or b.shape[-1] not in (2, 3):
          msg = (
              "incompatible dimensions for cross product\n"
              "(dimension must be 2 or 3)"
          )
          raise ValueError(msg)
  
      # Create the output array
      shape = cupy.broadcast(a[..., 0], b[..., 0]).shape
      if a.shape[-1] == 3 or b.shape[-1] == 3:
          shape += (3,)
          # Check axisc is within bounds
          axisc = internal._normalize_axis_index(axisc, len(shape))
      dtype = cupy.promote_types(a.dtype, b.dtype)
      cp = cupy.empty(shape, dtype)
  
      # create local aliases for readability
      a0 = a[..., 0]
      a1 = a[..., 1]
      if a.shape[-1] == 3:
          a2 = a[..., 2]
      b0 = b[..., 0]
      b1 = b[..., 1]
      if b.shape[-1] == 3:
          b2 = b[..., 2]
      if cp.ndim != 0 and cp.shape[-1] == 3:
          cp0 = cp[..., 0]
          cp1 = cp[..., 1]
          cp2 = cp[..., 2]
  
      if a.shape[-1] == 2:
          if b.shape[-1] == 2:
              # a0 * b1 - a1 * b0
              cupy.multiply(a0, b1, out=cp)
              cp -= a1 * b0
              return cp
          else:
              assert b.shape[-1] == 3
              # cp0 = a1 * b2 - 0  (a2 = 0)
              # cp1 = 0 - a0 * b2  (a2 = 0)
              # cp2 = a0 * b1 - a1 * b0
              cupy.multiply(a1, b2, out=cp0)
              cupy.multiply(a0, b2, out=cp1)
              cupy.negative(cp1, out=cp1)
              cupy.multiply(a0, b1, out=cp2)
              cp2 -= a1 * b0
      else:
          assert a.shape[-1] == 3
          if b.shape[-1] == 3:
              # cp0 = a1 * b2 - a2 * b1
              # cp1 = a2 * b0 - a0 * b2
              # cp2 = a0 * b1 - a1 * b0
              cupy.multiply(a1, b2, out=cp0)
              tmp = a2 * b1
              cp0 -= tmp
              cupy.multiply(a2, b0, out=cp1)
              cupy.multiply(a0, b2, out=tmp)
              cp1 -= tmp
              cupy.multiply(a0, b1, out=cp2)
              cupy.multiply(a1, b0, out=tmp)
              cp2 -= tmp
          else:
              assert b.shape[-1] == 2
              # cp0 = 0 - a2 * b1  (b2 = 0)
              # cp1 = a2 * b0 - 0  (b2 = 0)
              # cp2 = a0 * b1 - a1 * b0
              cupy.multiply(a2, b1, out=cp0)
              cupy.negative(cp0, out=cp0)
              cupy.multiply(a2, b0, out=cp1)
              cupy.multiply(a0, b1, out=cp2)
              cp2 -= a1 * b0
  
      return cupy.moveaxis(cp, -1, axisc)
  
file_path: cupy/cupy/linalg/_product.py
imports: import collections.abc
  import numbers
  import numpy
  import cupy
  from cupy import _core
  from cupy._core import internal
  from cupy._core._gufuncs import _GUFunc
  from cupy.linalg import _solve
  from cupy.linalg import _util
label_desc: Use image node_id 3 for calling a global function with example usage: cross(a, b, axisa, axisb, axisc, axis) and returns: cupy, cp