code: def _double_backward_softmax_cross_entropy(
      x, t, normalize, class_weight, ignore_label, reduce, is_chainerx
  ):
      if isinstance(t, variable.Variable):
          t = t.data
  
      F = chainer.functions
  
      _check_class_weight_option(class_weight)
      _check_reduce_option(reduce)
      if chainer.is_debug():
          _check_input_values(x, t, ignore_label)
  
      loss = -chainer.functions.log_softmax(x)
  
      if class_weight is not None:
          shape = [1 if d != 1 else -1 for d in six.moves.range(x.ndim)]
          class_weight = F.broadcast_to(
              class_weight.reshape(shape), x.shape
          )
          # TODO(niboshi): Remove this workaround after ChainerX supports
          # type promotion.
          if is_chainerx:
              class_weight = F.cast(class_weight, x.dtype)
          loss = loss * class_weight
  
      in_use = (t != ignore_label).astype(x.dtype)
  
      loss = F.rollaxis(loss, 1, loss.ndim)
      loss = F.reshape(loss, (-1, loss.shape[-1]))
  
      # Replace ignore_label value with one valid for F.select_item below.
      t = t.clip(0, loss.shape[1] - 1)
  
      loss = F.select_item(loss, t.ravel())
      loss = F.reshape(loss, t.shape)
  
      loss = loss * in_use
  
      if reduce == "mean":
          reduc_dtype = _reduction_dtype(x.dtype)
          if normalize:
              # TODO(niboshi): Use in_use.sum(dtype=reduc_dtype) once chainerx
              # supports dtype argument.
              count = in_use.astype(reduc_dtype, copy=False).sum()
          else:
              count = len(x)
          count = max(count, 1.0)
  
          if reduc_dtype == loss.dtype:
              loss = F.sum(loss / count)
          else:
              # Sum in a promoted dtype
              loss = F.cast(loss, reduc_dtype)
              loss = F.sum(loss / count)
              loss = F.cast(loss, x.dtype)
  
      return loss
  
imports: import numpy
  import six
  import chainer
  from chainer import backend
  from chainer.backends import cuda
  from chainer import function_node
  from chainer.functions.activation import log_softmax
  from chainer.utils import type_check
  from chainer import variable
  import chainerx
label_desc: Use image node_id 6 for calling a global function with example usage: _double_backward_softmax_cross_entropy(x, t, normalize, class_weight, ignore_label, reduce, is_chainerx) and returns: loss