code: def forward(
      model: Model[InT, OutT], X: InT, is_train: bool
  ) -> Tuple[OutT, Callable]:
      nOs = model.attrs["nOs"]
      W = cast(Floats2d, model.get_param("W"))
      b = cast(Floats1d, model.get_param("b"))
  
      def backprop(dY: OutT) -> InT:
          model.inc_grad("W", model.ops.gemm(dY, X, trans1=True))
          model.inc_grad("b", dY.sum(axis=0))
          return model.ops.gemm(dY, W)
  
      Y = model.ops.gemm(X, W, trans2=True)
      Y += b
      i = 0
      for out_size in nOs:
          model.ops.softmax(Y[:, i : i + out_size], inplace=True)
          i += out_size
      return Y, backprop
  
imports: from typing import Callable, Optional, Tuple, cast
  from ..config import registry
  from ..model import Model
  from ..types import Floats1d, Floats2d
  from ..util import get_width
label_desc: Use image node_id 2 for calling a global function with example usage: forward(model, X, is_train) and returns: Y,  backprop, model