code: def pack_bitstrings(a, nbit):
      """
      Pack a set integers (i, j) where i=0:n and j=0:M into
      n bitstrings.
      Output is an uint8 array of size (n, code_size), where code_size is
      such that at most 7 bits per code are wasted.
  
      If nbit is an integer: all entries takes nbit bits.
      If nbit is an array: entry (i, j) takes nbit[j] bits.
      """
      n, M = a.shape
      a = np.ascontiguousarray(a, dtype="int32")
      if is_sequence(nbit):
          nbit = np.ascontiguousarray(nbit, dtype="int32")
          assert nbit.shape == (M,)
          code_size = int((nbit.sum() + 7) // 8)
          b = np.empty((n, code_size), dtype="uint8")
          pack_bitstrings_c(
              n, M, swig_ptr(nbit), swig_ptr(a), swig_ptr(b), code_size
          )
      else:
          code_size = (M * nbit + 7) // 8
          b = np.empty((n, code_size), dtype="uint8")
          pack_bitstrings_c(
              n, M, nbit, swig_ptr(a), swig_ptr(b), code_size
          )
      return b
  
imports: import numpy
  from faiss.loader import *
  import faiss
  import collections.abc
label_desc: Use image node_id 17 for calling a global function with example usage: pack_bitstrings(a, nbit) and returns: b