class_docstr: Class representing a general ImageNet-style hierarchy.
class_docstr_tok: ["Class","representing","a","general","ImageNet-style","hierarchy","."]
docstr: Determine the leaves (ImageNet classes) reachable for a give node.
  
  Args:
      n (str) : WordNet ID of node
  
  Returns:
      leaves (list): List of WordNet IDs of the ImageNet descendants
docstr_tok: ["Determine","the","leaves","(","ImageNet","classes",")","reachable","for","a","give","node",".","Args",":","n","(","str",")",":","WordNet","ID","of","node","Returns",":","leaves","(","list",")",":","List","of","WordNet","IDs","of","the","ImageNet","descendants"]
code: def leaves_reachable(self, n):
      """
      Determine the leaves (ImageNet classes) reachable for a give node.
  
      Args:
          n (str) : WordNet ID of node
  
      Returns:
          leaves (list): List of WordNet IDs of the ImageNet descendants
      """
      leaves = set()
      todo = [n]
      while todo:
          curr = todo
          todo = []
          for w in curr:
              for c in self.graph.successors(w):
                  if c in self.LEAF_IDS:
                      leaves.add(c)
                  else:
                      todo.append(c)
          todo = set(todo)
  
      # If the node itself is an ImageNet node
      if n in self.LEAF_IDS:
          leaves = leaves.union([n])
      return leaves
  
imports: import sys, os
  import json
  import numpy
  import pandas
  import urllib
  from collections import OrderedDict, Counter
  import operator
  import networkx
  from ..datasets import DATASETS
label_desc: Use image node_id 4 for calling the ClassHierarchy obj's underlying member method code with example usage: obj.leaves_reachable(n) and returns: leaves