code: def bilinear(e1, e2, W, V1=None, V2=None, b=None):
      """Applies a bilinear function based on given parameters.
  
      This is a building block of Neural Tensor Network (see the reference paper
      below). It takes two input variables and one or four parameters, and
      outputs one variable.
  
      To be precise, denote six input arrays mathematically by
      :math:`e^1\\in \\mathbb{R}^{I\\cdot J}`,
      :math:`e^2\\in \\mathbb{R}^{I\\cdot K}`,
      :math:`W\\in \\mathbb{R}^{J \\cdot K \\cdot L}`,
      :math:`V^1\\in \\mathbb{R}^{J \\cdot L}`,
      :math:`V^2\\in \\mathbb{R}^{K \\cdot L}`, and
      :math:`b\\in \\mathbb{R}^{L}`,
      where :math:`I` is mini-batch size.
      In this document, we call :math:`V^1`, :math:`V^2`, and :math:`b` linear
      parameters.
  
      The output of forward propagation is calculated as
  
      .. math::
  
        y_{il} = \\sum_{jk} e^1_{ij} e^2_{ik} W_{jkl} + \\
          \\sum_{j} e^1_{ij} V^1_{jl} + \\sum_{k} e^2_{ik} V^2_{kl} + b_{l}.
  
      Note that V1, V2, b are optional. If these are not given, then this
      function omits the last three terms in the above equation.
  
      .. note::
  
         This function accepts an input variable ``e1`` or ``e2`` of a non-matrix
         array. In this case, the leading dimension is treated as the batch
         dimension, and the other dimensions are reduced to one dimension.
  
      .. note::
  
         In the original paper, :math:`J` and :math:`K`
         must be equal and the author denotes :math:`[V^1 V^2]`
         (concatenation of matrices) by :math:`V`.
  
      Args:
          e1 (:class:`~chainer.Variable` or :ref:`ndarray`):
              Left input variable.
          e2 (:class:`~chainer.Variable` or :ref:`ndarray`):
              Right input variable.
          W (:class:`~chainer.Variable` or :ref:`ndarray`):
              Quadratic weight variable.
          V1 (:class:`~chainer.Variable` or :ref:`ndarray`):
              Left coefficient variable.
          V2 (:class:`~chainer.Variable` or :ref:`ndarray`):
              Right coefficient variable.
          b (:class:`~chainer.Variable` or :ref:`ndarray`):
              Bias variable.
  
      Returns:
          ~chainer.Variable: Output variable.
  
      See:
          `Reasoning With Neural Tensor Networks for Knowledge Base Completion
          <https://papers.nips.cc/paper/5028-reasoning-with-neural-tensor-
          networks-for-knowledge-base-completion>`_ [Socher+, NIPS2013].
  
      .. seealso::
  
          :class:`~chainer.links.Bilinear` to manage the model parameters
          ``W``, ``V1``, ``V2``, and ``b``.
  
      """
      flags = [V1 is None, V2 is None, b is None]
      if any(flags):
          if not all(flags):
              raise ValueError(
                  "All coefficients and bias for bilinear() must "
                  "be None, if at least one of them is None."
              )
          return BilinearFunction().apply((e1, e2, W))[0]
      return BilinearFunction().apply((e1, e2, W, V1, V2, b))[0]
  
imports: import numpy
  import chainer
  from chainer import backend
  from chainer import function_node
  from chainer.utils import type_check
label_desc: Use image node_id 6 for calling a global function with example usage: bilinear(e1, e2, W, V1, V2, b) and returns: BilinearFunction, BilinearFunction