code: def forward(
      model: Model[InT, OutT], Xr: InT, is_train: bool
  ) -> Tuple[OutT, Callable]:
      lengths = Xr.lengths
  
      def backprop(dXs: OutT) -> InT:
          return Ragged(
              model.ops.flatten(dXs, pad=0), lengths
          )  # type:ignore[arg-type]
          # type ignore necessary for older versions of Mypy/Pydantic
  
      data = cast(OutT, model.ops.unflatten(Xr.dataXd, Xr.lengths))
      return data, backprop
  
imports: from typing import Callable, Tuple, TypeVar, cast
  from ..config import registry
  from ..model import Model
  from ..types import ListXd, Ragged
label_desc: Use image node_id 2 for calling a global function with example usage: forward(model, Xr, is_train) and returns: data,  backprop, Ragged