code: def _compare_and_swap(
      x, desc_mask, n_dims: core.constexpr, idx: core.constexpr
  ):
      x_int = _cast_to_int(x)
      l_int = _take_slice(x_int, n_dims, idx, 0)
      r_int = _take_slice(x_int, n_dims, idx, 1)
      l = l_int.to(x.dtype, bitcast=True)
      r = r_int.to(x.dtype, bitcast=True)
  
      desc_mask = desc_mask.to(x_int.dtype)
      zero = zeros_like(x_int)
      y = x_int ^ core.where((l > r) ^ desc_mask, l_int ^ r_int, zero)
      y = y.to(x.dtype, bitcast=True)
      return y
  
imports: from __future__ import annotations
  from ..runtime.jit import jit
  from .None import core, math
label_desc: Use image node_id 30 for calling a global function with example usage: _compare_and_swap(x, desc_mask, n_dims, idx) and returns: y