code: def gen_searchcell_mask_from_arch_str(arch_str):
      nodes = arch_str.split("+")
      nodes = [node[1:-1].split("|") for node in nodes]
      nodes = [
          [op_and_input.split("~") for op_and_input in node]
          for node in nodes
      ]
  
      keep_mask = []
      for curr_node_idx in range(len(nodes)):
          for prev_node_idx in range(curr_node_idx + 1):
              _op = [
                  edge[0]
                  for edge in nodes[curr_node_idx]
                  if int(edge[1]) == prev_node_idx
              ]
              assert (
                  len(_op) == 1
              ), "The arch string does not follow the assumption of 1 connection between two nodes."
              for _op_name in OPS.keys():
                  keep_mask.append(_op[0] == _op_name)
      return keep_mask
  
file_path: singa/examples/model_selection/TRAILS-Database-Native-Model-Selection/internal/ml/model_selection/src/third_pkg/sp201_lib/nasbench2.py
imports: from .nasbench2_ops import *
label_desc: Use image node_id 1 for calling a global function with example usage: gen_searchcell_mask_from_arch_str(arch_str) and returns: keep_mask