code: def _append_bit_and_pending(
      bit: bool,
      pending_bits: int,
      int_array: ndarray,
      byte: int,
      idx: int,
      bit_idx: int,
  ) -> Tuple[ndarray, int, int, int]:
      """Append a single bit and a pending_bits rev. bits to an integer array."""
  
      def add_pending_bit(vals):
          pending_bits, bit, int_array, byte, idx, bit_idx = vals
  
          int_array, byte, idx, bit_idx = _append_bit(
              jnp.logical_not(bit), int_array, byte, idx, bit_idx
          )
          pending_bits -= 1
  
          return pending_bits, bit, int_array, byte, idx, bit_idx
  
      def condition(vals):
          return vals[0] > 0
  
      int_array, byte, idx, bit_idx = _append_bit(
          bit, int_array, byte, idx, bit_idx
      )
  
      _, _, int_array, byte, idx, bit_idx = lax.while_loop(
          condition,
          add_pending_bit,
          (pending_bits, bit, int_array, byte, idx, bit_idx),
      )
  
      return int_array, byte, idx, bit_idx
  
file_path: NeuralCompression/projects/jax_entropy_coders/jax_arithmetic_coder.py
imports: from typing import Any, Callable, List, Tuple
  import jax
  import jax.lax
  import jax.numpy
  from jax.numpy import ndarray
label_desc: Use image node_id 2 for calling a global function with example usage: _append_bit_and_pending(bit, pending_bits, int_array, byte, idx, bit_idx) and returns: int_array,  byte,  idx,  bit_idx, pending_bits,  bit,  int_array,  byte,  idx,  bit_idx, unknown