code: def lapmod(n, cc, ii, kk, fast=True, return_cost=True,
             fp_version=FP_DYNAMIC):
      check_cost(n, cc, ii, kk)
      if fast is True:
          x, y = _lapmod(n, cc, ii, kk, fp_version=fp_version)
      else:
          cc = np.ascontiguousarray(cc, dtype=np.float64)
          ii = np.ascontiguousarray(ii, dtype=np.int32)
          kk = np.ascontiguousarray(kk, dtype=np.int32)
          x = np.empty((n,), dtype=np.int32)
          y = np.empty((n,), dtype=np.int32)
          v = np.empty((n,), dtype=np.float64)
          free_rows = np.empty((n,), dtype=np.int32)
          n_free_rows = _pycrrt(n, cc, ii, kk, free_rows, x, y, v)
          if n_free_rows == 0:
              if return_cost is True:
                  return get_cost(n, cc, ii, kk, x), x, y
              else:
                  return x, y
          for it in range(2):
              n_free_rows = _pyarr(
                      n, cc, ii, kk, n_free_rows, free_rows, x, y, v)
              if n_free_rows == 0:
                  if return_cost is True:
                      return get_cost(n, cc, ii, kk, x), x, y
                  else:
                      return x, y
          _pya(n, cc, ii, kk, n_free_rows, free_rows, x, y, v)
      if return_cost is True:
          return get_cost(n, cc, ii, kk, x), x, y
      else:
          return x, y