code: def argmax_crf1d(cost, xs):
      """Computes a state that maximizes a joint probability of the given CRF.
  
      Args:
          cost (:class:`~chainer.Variable` or :ref:`ndarray`):
              A :math:`K \\times K` matrix which holds transition
              cost between two labels, where :math:`K` is the number of labels.
          xs (list of Variable): Input vector for each label.
              ``len(xs)`` denotes the length of the sequence,
              and each :class:`~chainer.Variable` holds a :math:`B \\times K`
              matrix, where :math:`B` is mini-batch size, :math:`K` is the number
              of labels.
              Note that :math:`B`\\ s in all the variables are not necessary
              the same, i.e., it accepts the input sequences with different
              lengths.
  
      Returns:
          tuple: A tuple of :class:`~chainer.Variable` object ``s`` and a
          :class:`list` ``ps``.
          The shape of ``s`` is ``(B,)``, where ``B`` is the mini-batch size.
          i-th element of ``s``, ``s[i]``, represents log-likelihood of i-th
          data.
          ``ps`` is a list of :ref:`ndarray`, and denotes the state that
          maximizes the point probability.
          ``len(ps)`` is equal to ``len(xs)``, and shape of each ``ps[i]`` is
          the mini-batch size of the corresponding ``xs[i]``. That means,
          ``ps[i].shape == xs[i].shape[0:1]``.
      """
      alpha = xs[0]
      alphas = []
      max_inds = []
      for x in xs[1:]:
          batch = x.shape[0]
          if alpha.shape[0] > batch:
              alpha, alpha_rest = split_axis.split_axis(
                  alpha, [batch], axis=0
              )
              alphas.append(alpha_rest)
          else:
              alphas.append(None)
          b_alpha, b_cost = broadcast.broadcast(alpha[..., None], cost)
          scores = b_alpha + b_cost
          max_ind = minmax.argmax(scores, axis=1)
          max_inds.append(max_ind)
          alpha = minmax.max(scores, axis=1) + x
  
      inds = minmax.argmax(alpha, axis=1)
      path = [inds.data]
      for m, a in zip(max_inds[::-1], alphas[::-1]):
          inds = select_item.select_item(m, inds)
          if a is not None:
              inds = concat.concat(
                  [inds, minmax.argmax(a, axis=1)], axis=0
              )
          path.append(inds.data)
      path.reverse()
  
      score = minmax.max(alpha, axis=1)
      for a in alphas[::-1]:
          if a is None:
              continue
          score = concat.concat([score, minmax.max(a, axis=1)], axis=0)
  
      return score, path
  
file_path: chainer/chainer/functions/loss/crf1d.py
imports: from chainer.functions.array import broadcast
  from chainer.functions.array import concat
  from chainer.functions.array import reshape
  from chainer.functions.array import select_item
  from chainer.functions.array import split_axis
  from chainer.functions.connection import embed_id
  from chainer.functions.math import logsumexp
  from chainer.functions.math import minmax
  from chainer.functions.math import sum
label_desc: Use image node_id 2 for calling a global function with example usage: argmax_crf1d(cost, xs) and returns: score,  path