class_docstr: Class for representing ImageNet/WordNet hierarchy. 
class_docstr_tok: ["Class","for","representing","ImageNet\/WordNet","hierarchy","."]
docstr: Get ImageNet subclasses for a given set of superclasses from the WordNet 
  hierarchy. 
  
  Args:
      superclass_wnid (list): List of WordNet IDs of superclasses
      balanced (bool) : If True, all the superclasses will have the same number
                      of ImageNet subclasses
  
  Returns:
      class_ranges (list of sets): List of ImageNet subclasses per superclass
      label_map (dict): Mapping from class number to human-interpretable description
                      for each superclass
docstr_tok: ["Get","ImageNet","subclasses","for","a","given","set","of","superclasses","from","the","WordNet","hierarchy",".","Args",":","superclass_wnid","(","list",")",":","List","of","WordNet","IDs","of","superclasses","balanced","(","bool",")",":","If","True",",","all","the","superclasses","will","have","the","same","number","of","ImageNet","subclasses","Returns",":","class_ranges","(","list","of","sets",")",":","List","of","ImageNet","subclasses","per","superclass","label_map","(","dict",")",":","Mapping","from","class","number","to","human-interpretable","description","for","each","superclass"]
code: def get_subclasses(self, superclass_wnid, balanced=True):
      """
      Get ImageNet subclasses for a given set of superclasses from the WordNet
      hierarchy.
  
      Args:
          superclass_wnid (list): List of WordNet IDs of superclasses
          balanced (bool) : If True, all the superclasses will have the same number
                          of ImageNet subclasses
  
      Returns:
          class_ranges (list of sets): List of ImageNet subclasses per superclass
          label_map (dict): Mapping from class number to human-interpretable description
                          for each superclass
      """
      ndesc_min = min(
          [self.tree[w].descendant_count_in for w in superclass_wnid]
      )
      class_ranges, label_map = [], {}
      for ii, w in enumerate(superclass_wnid):
          descendants = self.get_descendants(w, in_imagenet=True)
          if balanced and len(descendants) > ndesc_min:
              descendants = set(
                  [
                      dd
                      for ii, dd in enumerate(sorted(list(descendants)))
                      if ii < ndesc_min
                  ]
              )
          class_ranges.append(descendants)
          label_map[ii] = self.tree[w].name
  
      for i in range(len(class_ranges)):
          for j in range(i + 1, len(class_ranges)):
              assert (
                  len(class_ranges[i].intersection(class_ranges[j]))
                  == 0
              )
  
      return class_ranges, label_map
  
file_path: robustness/robustness/tools/imagenet_helpers.py
imports: import os
  import numpy
  import json
  from itertools import product
label_desc: Use image node_id 7 for calling the ImageNetHierarchy obj's underlying member method code with example usage: obj.get_subclasses(superclass_wnid, balanced) and returns: class_ranges,  label_map