class_docstr: TreeLSTM unit with N forget gates.
  
  This have variable inputs ``(c1, c2, ..., cN, x)``
  where ``x`` is (3 + N) times larger than each cell.
  Forget gates ``(f1, f2, ..., fN)`` can depend in
  different partitions of ``x[:, 3 * cell_units:]``.
  There are two outputs ``(c, h)``.
class_docstr_tok: ["TreeLSTM","unit","with","N","forget","gates",".","This","have","variable","inputs","``","(","c1",",","c2",",","...",",","cN",",","x",")","``","where","``","x","``","is","(","3","+","N",")","times","larger","than","each","cell",".","Forget","gates","``","(","f1",",","f2",",","...",",","fN",")","``","can","depend","in","different","partitions","of","``","x","[",":",",","3","*","cell_units",":","]","``",".","There","are","two","outputs","``","(","c",",","h",")","``","."]
code: def forward(self, inputs):
      cs, x = inputs[:-1], inputs[-1]
      n_ary = len(cs)
      gates = list(_extract_gates(x, 3 + n_ary))
      a, i, o = gates[:3]
      fs = gates[3:]
  
      if isinstance(x, chainer.get_cpu_array_types()):
          self.a = numpy.tanh(a)
          self.i = _sigmoid(i)
          self.o = _sigmoid(o)
          self.fs = [_sigmoid(f) for f in fs]
  
          self.c = self.a * self.i + sum(
              f * c for f, c in zip(self.fs, cs)
          )
          h = self.o * numpy.tanh(self.c)
      else:
          preamble = _preamble + " ".join(
              "T af{} = sigmoid(f{});".format(j, j)
              for j in six.moves.range(1, n_ary + 1)
          )
          cells_str = ", ".join(
              "T c{}".format(j) for j in six.moves.range(1, n_ary + 1)
          )
          fgates_str = ", ".join(
              "T f{}".format(j) for j in six.moves.range(1, n_ary + 1)
          )
          fc_calc_str = " + ".join(
              "af{} * c{}".format(j, j)
              for j in six.moves.range(1, n_ary + 1)
          )
          self.c, h = cuda.elementwise(
              "T a, T i_, T o, {}, {}".format(cells_str, fgates_str),
              "T c, T h",
              """
                      COMMON_ROUTINE;
                      c = aa * ai + {};
                      h = ao * tanh(c);
                  """.format(
                  fc_calc_str
              ),
              "treelstm_fwd",
              preamble=preamble,
          )(a, i, o, *(list(cs) + fs))
  
      return self.c, h
  
file_path: chainer/chainer/functions/rnn/tree_lstm.py
imports: import numpy
  import six
  import chainer
  from chainer import backend
  from chainer.backends import cuda
  from chainer import function
  from chainer.utils import type_check
  import chainerx
label_desc: Use image node_id 3 for calling the TreeLSTM obj's underlying member method code with example usage: obj.forward(inputs) and returns: self,  h