code: def print_unpack_bit_func(self, bit):
      def p(code):
          print(indent(code, prefix="  "))
  
      shift = 0
      shifts = []
      in_index = 0
      inls = []
      mask = (1 << bit) - 1
      bracket = "{"
  
      print(
          f"inline static const uint32_t* unpack{bit}_32(const uint32_t* in, uint32_t* out) {{"
      )
      p(
          dedent(
              f"""\
              uint32_t mask = 0x{mask:0x};
  
              simd_batch masks(mask);
              simd_batch words, shifts;
              simd_batch results;
              """
          )
      )
  
      def safe_load(index):
          return f"SafeLoad<uint32_t>(in + {index})"
  
      for i in range(32):
          if shift + bit == 32:
              shifts.append(shift)
              inls.append(safe_load(in_index))
              in_index += 1
              shift = 0
          elif shift + bit > 32:  # cross the boundary
              inls.append(
                  f"{safe_load(in_index)} >> {shift} | {safe_load(in_index + 1)} << {32 - shift}"
              )
              in_index += 1
              shift = bit - (32 - shift)
              shifts.append(0)  # zero shift
          else:
              shifts.append(shift)
              inls.append(safe_load(in_index))
              shift += bit
  
      bytes_per_batch = self.simd_byte_width
      words_per_batch = bytes_per_batch // 4
  
      one_word_template = dedent(
          """\
              words = simd_batch{{ {words} }};
              shifts = simd_batch{{ {shifts} }};
              results = (words >> shifts) & masks;
              results.store_unaligned(out);
              out += {words_per_batch};
              """
      )
  
      for start in range(0, 32, words_per_batch):
          stop = start + words_per_batch
          p(f"""// extract {bit}-bit bundles {start} to {stop - 1}""")
          p(
              one_word_template.format(
                  words=", ".join(inls[start:stop]),
                  shifts=", ".join(map(str, shifts[start:stop])),
                  words_per_batch=words_per_batch,
              )
          )
  
      p(
          dedent(
              f"""\
              in += {bit};
              return in;"""
          )
      )
      print("}")
  
file_path: arrow/cpp/src/arrow/util/bpacking_simd_codegen.py
imports: from functools import partial
  import sys
  from textwrap import dedent, indent
label_desc: Use image node_id 4 for calling the UnpackGenerator obj's underlying member method code with example usage: obj.print_unpack_bit_func(bit) and returns: str, index, str