class_docstr: Hierarchical softmax function based on a binary tree.
  
  This function object should be allocated beforehand, and be copied on every
  forward computation, since the initializer parses the given tree. See the
  implementation of :class:`BinaryHierarchicalSoftmax` for details.
  
  Args:
      tree: A binary tree made with tuples like ``((1, 2), 3)``.
  
  .. seealso::
     See :class:`BinaryHierarchicalSoftmax` for details.
code: def __init__(self, tree, dtype):
      device_resident.DeviceResident.__init__(self)
  
      parser = TreeParser(dtype)
      parser.parse(tree)
      paths = parser.get_paths()
      codes = parser.get_codes()
      n_vocab = max(paths.keys()) + 1
  
      self.paths = numpy.concatenate(
          [paths[i] for i in range(n_vocab) if i in paths]
      )
      self.codes = numpy.concatenate(
          [codes[i] for i in range(n_vocab) if i in codes]
      )
      begins = numpy.empty((n_vocab + 1,), dtype=numpy.int32)
      begins[0] = 0
      for i in range(0, n_vocab):
          length = len(paths[i]) if i in paths else 0
          begins[i + 1] = begins[i] + length
      self.begins = begins
  
      self.parser_size = parser.size()
  
imports: import copy
  import numpy
  import six
  import chainer
  from chainer.backends import cuda
  from chainer import device_resident
  from chainer import function
  from chainer.initializers import uniform
  from chainer import link
  from chainer import utils
  from chainer.utils import type_check
  from chainer import variable
label_desc: Use image node_id 1 to create a new BinaryHierarchicalSoftmaxFunction object from inherited base classes: device_resident, function with example: obj = BinaryHierarchicalSoftmaxFunction(tree, dtype)