code: def _padded_forward(
      layer: Model[Ragged, Ragged], Xp: Padded, is_train: bool
  ) -> Tuple[Padded, Callable]:
      # Assign these to locals, to keep code a bit shorter.
      list2padded = layer.ops.list2padded
      padded2list = layer.ops.padded2list
      unflatten = layer.ops.unflatten
      flatten = layer.ops.flatten
      # It's worth being a bit careful about memory here, as the activations
      # are potentially large on GPU. So we make nested function calls instead
      # of assigning to temporaries where possible, so memory can be reclaimed
      # sooner.
      Xs = padded2list(Xp)
      # Bit annoying here: padded is in a different order, so we need to make new
      # lengths. The lengths are unconditionally allocated in CPU memory, because
      # otherwire unflatten would move GPU allocations to the CPU again. For the
      # ragged arrays we let the layer's ops determine how lengths should be
      # stored to ensure that the array and lengths use the same type of memory.
      lengths = NUMPY_OPS.asarray1i([len(x) for x in Xs])
      Yr, get_dXr = layer(
          Ragged(flatten(Xs), layer.ops.asarray1i(lengths)), is_train
      )
  
      def backprop(dYp: Padded):
          flattened = flatten(padded2list(dYp))
          dXr = get_dXr(Ragged(flattened, lengths))
          return list2padded(unflatten(dXr.data, lengths))
  
      return (
          list2padded(unflatten(Yr.data, Yr.lengths)),
          backprop,
      )
  
file_path: thinc/thinc/layers/with_ragged.py
imports: from typing import Callable, List, Optional, Tuple, TypeVar, Union, cast
  from ..backends import NumpyOps
  from ..config import registry
  from ..model import Model
  from ..types import Array2d, Ints1d, List2d, ListXd, Padded, Ragged
label_desc: Use image node_id 7 for calling a global function with example usage: _padded_forward(layer, Xp, is_train) and returns: list2padded,  backprop, list2padded