code: def cluster_types(types, max_clust=12):
      
  
      if len(types) < max_clust:
          max_clust = len(types)
  
      # Do actual clustering
      cluster_dict = do_clustering(types, max_clust)
      cluster_ranks = rank_clusters(cluster_dict)
  
      # Create a dictionary mapping binary numbers to indices
      ranks = {}
      for key in cluster_dict:
          for typ in cluster_dict[key]:
              ranks[typ] = cluster_ranks[key]
  
      return ranks
docs: Generates a dictionary mapping each binary number in types to an integer
      from 0 to max_clust. Hierarchical clustering is used to determine which
      which binary numbers should map to the same integer.