code: def forward(
      model: Model[InT, OutT], X: InT, is_train: bool
  ) -> Tuple[OutT, Callable]:
      if not model.layers:
          return X, lambda dY: dY
      Y, first_callback = model.layers[0](X, is_train=is_train)
      callbacks = []
      for layer in model.layers[1:]:
          layer_Y, layer_callback = layer(X, is_train=is_train)
          Y += layer_Y
          callbacks.append(layer_callback)
  
      def backprop(dY: InT) -> OutT:
          dX = first_callback(dY)
          for callback in callbacks:
              dX += callback(dY)
          return dX
  
      return Y, backprop
  
imports: from typing import Any, Callable, Dict, Optional, Tuple, TypeVar
  from ..config import registry
  from ..model import Model
  from ..types import ArrayXd, XY_XY_OutT
  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, X,  function, dX