class_docstr: Class representing a general ImageNet-style hierarchy.
class_docstr_tok: ["Class","representing","a","general","ImageNet-style","hierarchy","."]
docstr: Args:
      info_dir (str) : Path to hierarchy information files. Contains a 
          "class_hierarchy.txt" file with one edge per line, a
          "node_names.txt" mapping nodes to names, and "class_info.json".
docstr_tok: ["Args",":","info_dir","(","str",")",":","Path","to","hierarchy","information","files",".","Contains","a","``","class_hierarchy.txt","''","file","with","one","edge","per","line",",","a","``","node_names.txt","''","mapping","nodes","to","names",",","and","``","class_info.json","''","."]
code: def __init__(self, info_dir, root_wnid="n00001740"):
      """
      Args:
          info_dir (str) : Path to hierarchy information files. Contains a
              "class_hierarchy.txt" file with one edge per line, a
              "node_names.txt" mapping nodes to names, and "class_info.json".
      """
  
      for f in REQUIRED_FILES:
          if not os.path.exists(os.path.join(info_dir, f)):
              raise Exception(
                  f"Missing files: `info_dir` does not "
                  "contain required file {f}"
              )
  
      # Details about dataset class names (leaves), IDS
      with open(os.path.join(info_dir, "dataset_class_info.json")) as f:
          class_info = json.load(f)
  
      # Hierarchy represented as edges between parent & child nodes.
      with open(os.path.join(info_dir, "class_hierarchy.txt")) as f:
          edges = [l.strip().split() for l in f.readlines()]
  
      # Information (names, IDs) for intermediate nodes in hierarchy.
      with open(os.path.join(info_dir, "node_names.txt")) as f:
          mapping = [l.strip().split("\t") for l in f.readlines()]
  
      # Original dataset classes
      self.LEAF_IDS = [c[1] for c in class_info]
      self.LEAF_ID_TO_NAME = {c[1]: c[2] for c in class_info}
      self.LEAF_ID_TO_NUM = {c[1]: c[0] for c in class_info}
      self.LEAF_NUM_TO_NAME = {c[0]: c[2] for c in class_info}
  
      # Full hierarchy
      self.HIER_NODE_NAME = {w[0]: w[1] for w in mapping}
      self.graph = self._make_parent_graph(self.LEAF_IDS, edges)
  
      # Arrange nodes in levels (top-down)
      self.node_to_level = self._make_level_dict(
          self.graph, root=root_wnid
      )
      self.level_to_nodes = {}
      for k, v in self.node_to_level.items():
          if v not in self.level_to_nodes:
              self.level_to_nodes[v] = []
          self.level_to_nodes[v].append(k)
  
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 1 to create a new ClassHierarchy object  with example: obj = ClassHierarchy(info_dir, root_wnid)