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 backward(self, inputs, grad_outputs):
      xp = backend.get_array_module(*inputs)
      cs, x = inputs[:-1], inputs[-1]
      n_ary = len(cs)
      gc, gh = grad_outputs
  
      gx = xp.empty_like(x)
      gates = list(_extract_gates(gx, 3 + n_ary))
      ga, gi, go = gates[:3]
      gfs = gates[3:]
  
      # Consider the case that either gradient is not given
      if gc is None:
          gc = 0
      if gh is None:
          gh = 0
  
      if xp is numpy:
          co = numpy.tanh(self.c)
          tmp = gh * self.o * _grad_tanh(co) + gc
          ga[:] = tmp * self.i * _grad_tanh(self.a)
          gi[:] = tmp * self.a * _grad_sigmoid(self.i)
          go[:] = gh * co * _grad_sigmoid(self.o)
  
          gcs = []
          for j in six.moves.range(0, n_ary):
              gfs[j][:] = tmp * cs[j] * _grad_sigmoid(self.fs[j])
              gcs.append(tmp * self.fs[j])
      else:
          gates = list(_extract_gates(x, 3 + n_ary))
          a, i, o = gates[:3]
          fs = gates[3:]
          gcs = [xp.empty_like(c) for c in cs]
          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)
          )
          g_cells_str = ", ".join(
              "T gc{}".format(j) for j in six.moves.range(1, n_ary + 1)
          )
          g_fgates_str = ", ".join(
              "T gf{}".format(j) for j in six.moves.range(1, n_ary + 1)
          )
          gf_calc_str = "\n    ".join(
              "gf{} = temp * c{} * grad_sigmoid(af{});".format(j, j, j)
              for j in six.moves.range(1, n_ary + 1)
          )
          gc_calc_str = "\n    ".join(
              "gc{} = temp * af{};".format(j, j)
              for j in six.moves.range(1, n_ary + 1)
          )
          cuda.elementwise(
              "T c, T gc, T gh, T a, T i_, T o, "
              + "{}, {}".format(cells_str, fgates_str),
              "T ga, T gi, T go, {}, {}".format(
                  g_cells_str, g_fgates_str
              ),
              """
                      COMMON_ROUTINE;
                      T co = tanh(c);
                      T temp = gh * ao * grad_tanh(co) + gc;
                      ga = temp * ai * grad_tanh(aa);
                      gi = temp * aa * grad_sigmoid(ai);
                      go = gh * co * grad_sigmoid(ao);
                      {}
                      {}
                  """.format(
                  gf_calc_str, gc_calc_str
              ),
              "treelstm_bwd",
              preamble=preamble,
          )(
              self.c,
              gc,
              gh,
              a,
              i,
              o,
              *(list(cs) + fs + [ga, gi, go] + gcs + gfs),
          )
  
      return list(gcs) + [gx]
  
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 4 for calling the TreeLSTM obj's underlying member method code with example usage: obj.backward(inputs, grad_outputs) and returns: unknown