def _idx_to_bits(i, bucket_length):
    """Convert an group index to its bit representation."""
    bits = bin(i)[2:].zfill(bucket_length)  # Pad the bits str with 0
    return [-1.0 if b == "0" else 1.0 for b in bits]