class_docstr: Graph & high-dimensional data visualization.
  
  Given a graph or high-dimensional vectors, it maps each node to 2D or 3D coordinates to
  faciliate visualization. The learned coordinates preserve most local similarity information
  of the original input, and may shed some light on the structure of the graph or the
  high-dimensional space.
  
  Supported Models:
      - LargeVis (`Visualizing Large-scale and High-dimensional Data`_)
  
  .. _Visualizing Large-scale and High-dimensional Data: https://arxiv.org/pdf/1602.00370.pdf
  
  Parameters:
      dim (int): dimension of embeddings
      gpus (list of int, optional): GPU ids, default is all GPUs
      cpu_per_gpu (int, optional): number of CPU threads per GPU, default is all CPUs
      float_type (dtype, optional): type of parameters
      index_type (dtype, optional): type of graph indexes
  
  See also:
      :class:`Graph <graphvite.graph.Graph>`,
      :class:`KNNGraph <graphvite.graph.KNNGraph>`,
      :class:`VisualizationSolver <graphvite.solver.VisualizationSolver>`
class_docstr_tok: ["Graph","&","high-dimensional","data","visualization",".","Given","a","graph","or","high-dimensional","vectors",",","it","maps","each","node","to","2D","or","3D","coordinates","to","faciliate","visualization",".","The","learned","coordinates","preserve","most","local","similarity","information","of","the","original","input",",","and","may","shed","some","light","on","the","structure","of","the","graph","or","the","high-dimensional","space",".","Supported","Models",":","-","LargeVis","(","`","Visualizing","Large-scale","and","High-dimensional","Data","`","_",")","..","_Visualizing","Large-scale","and","High-dimensional","Data",":","https",":","\/\/arxiv.org\/pdf\/1602.00370.pdf","Parameters",":","dim","(","int",")",":","dimension","of","embeddings","gpus","(","list","of","int",",","optional",")",":","GPU","ids",",","default","is","all","GPUs","cpu_per_gpu","(","int",",","optional",")",":","number","of","CPU","threads","per","GPU",",","default","is","all","CPUs","float_type","(","dtype",",","optional",")",":","type","of","parameters","index_type","(","dtype",",","optional",")",":","type","of","graph","indexes","See","also",":",":","class",":","`","Graph","<","graphvite.graph.Graph",">","`",",",":","class",":","`","KNNGraph","<","graphvite.graph.KNNGraph",">","`",",",":","class",":","`","VisualizationSolver","<","graphvite.solver.VisualizationSolver",">","`"]
docstr: Visualize learned 2D coordinates with hierarchical labels.
  
  Parameters:
      HY (list of list of str, optional): hierarchical labels of vectors
      file_name (str, optional): file of hierarchical labels
      target (str): target class
      save_file (str): ``gif`` file to save visualization
      figure_size (int, optional): size of figure
      scale (int, optional): size of points
      duration (float, optional): duration of each frame in seconds
docstr_tok: ["Visualize","learned","2D","coordinates","with","hierarchical","labels",".","Parameters",":","HY","(","list","of","list","of","str",",","optional",")",":","hierarchical","labels","of","vectors","file_name","(","str",",","optional",")",":","file","of","hierarchical","labels","target","(","str",")",":","target","class","save_file","(","str",")",":","``","gif","``","file","to","save","visualization","figure_size","(","int",",","optional",")",":","size","of","figure","scale","(","int",",","optional",")",":","size","of","points","duration","(","float",",","optional",")",":","duration","of","each","frame","in","seconds"]
code: def hierarchy(
      self,
      HY=None,
      file_name=None,
      target=None,
      save_file=None,
      figure_size=10,
      scale=2,
      duration=3,
  ):
      """
      Visualize learned 2D coordinates with hierarchical labels.
  
      Parameters:
          HY (list of list of str, optional): hierarchical labels of vectors
          file_name (str, optional): file of hierarchical labels
          target (str): target class
          save_file (str): ``gif`` file to save visualization
          figure_size (int, optional): size of figure
          scale (int, optional): size of points
          duration (float, optional): duration of each frame in seconds
      """
      import imageio
      from matplotlib import pyplot as plt
  
      plt.switch_backend("agg")  # for compatibility
  
      self.solver.clear()
  
      coordinates = self.solver.coordinates
      dim = coordinates.shape[1]
      if dim != 2:
          raise ValuerError(
              "Can't visualize the hierarchy of %dD data" % dim
          )
  
      if file_name:
          if not (HY is None):
              raise ValueError(
                  "Evaluation data and file should not be provided at the same time"
              )
          HY = []
          with open(file_name, "r") as fin:
              for line in fin:
                  tokens = self.tokenize(line)
                  if len(tokens) > 0:
                      HY.append(tokens)
      elif HY is None:
          raise ValueError("No label is provided for hierarchy")
      HY = np.asarray(HY)
      min_type = "S%d" % len("else")
      if HY.dtype < min_type:
          HY = HY.astype(min_type)
  
      mean = np.mean(coordinates, axis=0)
      std = np.std(coordinates, axis=0)
      inside = np.abs(coordinates - mean) < self.OUTLIER_THRESHOLD * std
      (indexes,) = np.where(np.all(inside, axis=1))
      # discard outliers
      coordinates = coordinates[indexes]
      HY = HY[indexes].T
  
      if target is None:
          raise ValueError("Target class is not provided")
      for depth, Y in enumerate(HY):
          (indexes,) = np.where(Y == target)
          if len(indexes) > 0:
              sample = indexes[0]
              break
      else:
          raise ValueError(
              "Can't find target `%s` in the hierarchy" % target
          )
  
      settings = [
          (coordinates, None, HY[0], sample, figure_size, scale, 0)
      ]
      for i in range(depth):
          settings.append(
              (
                  coordinates,
                  HY[i],
                  HY[i + 1],
                  sample,
                  figure_size,
                  scale,
                  i + 1,
              )
          )
      pool = multiprocessing.Pool(
          self.solver.num_worker + self.solver.num_sampler
      )
      frames = pool.map(render_hierarchy, settings)
      logger.warning("save hierarchy to `%s`" % save_file)
      imageio.mimsave(
          save_file, frames, fps=1 / duration, subrectangles=True
      )
  
      return {}
  
imports: from __future__ import print_function, absolute_import, unicode_literals, division
  import os
  import re
  import pickle
  import logging
  import multiprocessing
  from collections import defaultdict
  from future.builtins import str, map, range
  from easydict import EasyDict
  import numpy
  from ..None import lib, cfg, auto
  from ..None import graph, solver
  from ..util import assert_in, monitor, SharedNDArray
label_desc: Use image node_id 5 for calling the VisualizationApplication obj's underlying member method code with example usage: obj.hierarchy(HY, file_name, target, save_file, figure_size, scale, duration) and returns: dict