code: def ca_cfar(array, guard_cells, reference_cells, pfa=1e-3):
      """
      Computes the cell-averaged constant false alarm rate (CA CFAR) detector
      threshold and returns for a given array.
  
      Parameters
      ----------
      array : ndarray
          Array containing data to be processed.
  
      guard_cells_x : int
          One-sided guard cell count in the first dimension.
  
      guard_cells_y : int
          One-sided guard cell count in the second dimension.
  
      reference_cells_x : int
          one-sided reference cell count in the first dimension.
  
      reference_cells_y : int
          one-sided referenc cell count in the second dimension.
  
      pfa : float
          Probability of false alarm.
  
      Returns
      -------
      threshold : ndarray
          CFAR threshold
      return : ndarray
          CFAR detections
      """
      shape = array.shape
      if len(shape) > 2:
          raise TypeError(
              "Only 1D and 2D arrays are currently supported."
          )
      mask = cp.zeros(shape, dtype=cp.float32)
  
      if len(shape) == 1:
          if len(array) <= 2 * guard_cells + 2 * reference_cells:
              raise ValueError("Array too small for given parameters")
          intermediate = cp.cumsum(array, axis=0, dtype=cp.float32)
          N = 2 * reference_cells
          alpha = cfar_alpha(pfa, N)
          tpb = (32,)
          bpg = (
              (
                  len(array)
                  - 2 * reference_cells
                  - 2 * guard_cells
                  + tpb[0]
                  - 1
              )
              // tpb[0],
          )
          _ca_cfar_1d_kernel(
              bpg,
              tpb,
              (
                  array,
                  intermediate,
                  mask,
                  len(array),
                  N,
                  cp.float32(alpha),
                  guard_cells,
                  reference_cells,
              ),
          )
      elif len(shape) == 2:
          if len(guard_cells) != 2 or len(reference_cells) != 2:
              raise TypeError(
                  "Guard and reference cells must be two "
                  "dimensional."
              )
          guard_cells_x, guard_cells_y = guard_cells
          reference_cells_x, reference_cells_y = reference_cells
          if shape[0] - 2 * guard_cells_x - 2 * reference_cells_x <= 0:
              raise ValueError(
                  "Array first dimension too small for given "
                  "parameters."
              )
          if shape[1] - 2 * guard_cells_y - 2 * reference_cells_y <= 0:
              raise ValueError(
                  "Array second dimension too small for given "
                  "parameters."
              )
          intermediate = cp.cumsum(array, axis=0, dtype=cp.float32)
          intermediate = cp.cumsum(
              intermediate, axis=1, dtype=cp.float32
          )
          N = (
              2
              * reference_cells_x
              * (2 * reference_cells_y + 2 * guard_cells_y + 1)
          )
          N += 2 * (2 * guard_cells_x + 1) * reference_cells_y
          alpha = cfar_alpha(pfa, N)
          tpb = (8, 8)
          bpg_x = (
              shape[0]
              - 2 * (reference_cells_x + guard_cells_x)
              + tpb[0]
              - 1
          ) // tpb[0]
          bpg_y = (
              shape[1]
              - 2 * (reference_cells_y + guard_cells_y)
              + tpb[1]
              - 1
          ) // tpb[1]
          bpg = (bpg_x, bpg_y)
          _ca_cfar_2d_kernel(
              bpg,
              tpb,
              (
                  array,
                  intermediate,
                  mask,
                  shape[0],
                  shape[1],
                  N,
                  cp.float32(alpha),
                  guard_cells_x,
                  guard_cells_y,
                  reference_cells_x,
                  reference_cells_y,
              ),
          )
      return (mask, array - mask > 0)
  
imports: from math import ceil, log2
  import cupy
  from ..windows.windows import get_window
label_desc: Use image node_id 5 for calling a global function with example usage: ca_cfar(array, guard_cells, reference_cells, pfa) and returns: mask,  unknown