class_docstr: Softmax activation followed by a cross entropy loss.
class_docstr_tok: ["Softmax","activation","followed","by","a","cross","entropy","loss","."]
code: def forward_gpu(self, inputs):
      class_weight = backend.from_chx(self.class_weight)
  
      self.retain_inputs((0, 1))
      x, t = inputs
      if x.ndim == t.ndim and x.shape == t.shape:
          self.soft_target = True
      cupy = cuda.cupy
      if chainer.is_debug() and not self.soft_target:
          _check_input_values(x, t, self.ignore_label)
  
      if x.size == 0:
          y = cupy.zeros(t.shape, dtype=x.dtype)
          if self.cache_score:
              self.y = y
          if self.reduce == "mean":
              return (y.sum(),)
          else:
              return (y,)
      log_y = log_softmax._log_softmax(x)
      if self.cache_score:
          self.y = cupy.exp(log_y)
  
      if self.soft_target:
          return self._soft_target_loss(cupy, x, t, log_y)
  
      if class_weight is not None:
          shape = [1 if d != 1 else -1 for d in six.moves.range(x.ndim)]
          log_y *= cupy.broadcast_to(
              class_weight.reshape(shape), x.shape
          )
  
      log_y = cupy.rollaxis(log_y, 1, log_y.ndim)
  
      if self.reduce == "mean":
          # Reduction is performed in a promoted dtype
          reduc_dtype = _reduction_dtype(x.dtype)
          if self.normalize:
              count = (t != self.ignore_label).sum(dtype=reduc_dtype)
              count = cupy.maximum(1, count)
              coeff = 1.0 / count
          else:
              coeff = cupy.array(
                  1.0 / max(1, len(t)), dtype=reduc_dtype
              )
          self._coeff = coeff
  
          ret = cuda.reduce(
              "S t, raw T log_y, int32 n_channel, raw U coeff, "
              "S ignore_label",
              "U out",
              "t == ignore_label ? T(0) : log_y[_j * n_channel + t]",
              "a + b",
              "out = static_cast<U>(a * -coeff[0])",
              "0",
              "crossent_fwd",
          )(
              t,
              log_y.reduced_view(),
              log_y.shape[-1],
              self._coeff,
              self.ignore_label,
          )
          ret = ret.astype(log_y.dtype, copy=False)
      else:
          ret = cuda.elementwise(
              "S t, raw T log_y, int32 n_channel, T ignore",
              "T out",
              """
                  if (t == ignore) {
                    out = 0;
                  } else {
                    out = -log_y[i * n_channel + t];
                  }
                  """,
              "softmax_crossent_no_reduce_fwd",
          )(t, log_y.reduced_view(), log_y.shape[-1], self.ignore_label)
          ret = ret.reshape(t.shape)
      return (ret,)
  
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 the SoftmaxCrossEntropy obj's underlying member method code with example usage: obj.forward_gpu(inputs) and returns: ret, self, y, y