code: def gen_is_edge_fn(bits):
      """Generate a boolean function for the edge connectivity.
  
      Given a bitstring FEDCBA and a 4x4 matrix, the generated matrix is
        [[0, A, B, D],
         [0, 0, C, E],
         [0, 0, 0, F],
         [0, 0, 0, 0]]
  
      Note that this function is agnostic to the actual matrix dimension due to
      order in which elements are filled out (column-major, starting from least
      significant bit). For example, the same FEDCBA bitstring (0-padded) on a 5x5
      matrix is
        [[0, A, B, D, 0],
         [0, 0, C, E, 0],
         [0, 0, 0, F, 0],
         [0, 0, 0, 0, 0],
         [0, 0, 0, 0, 0]]
  
      Args:
        bits: integer which will be interpreted as a bit mask.
  
      Returns:
        vectorized function that returns True when an edge is present.
      """
  
      def is_edge(x, y):
          """Is there an edge from x to y (0-indexed)?"""
          if x >= y:
              return 0
          # Map x, y to index into bit string
          index = x + (y * (y - 1) // 2)
          return (bits >> index) % 2 == 1
  
      return np.vectorize(is_edge)
  
file_path: singa/examples/model_selection/TRAILS-Database-Native-Model-Selection/internal/ml/model_selection/src/third_pkg/sp101_lib/graph_util.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import hashlib
  import itertools
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: gen_is_edge_fn(bits) and returns: np, unknown, int