code: def with_array2d(
      layer: Model[ValT, ValT], pad: int = 0
  ) -> Model[SeqT, SeqT]:
      """Transform sequence data into a contiguous 2d array on the way into and
      out of a model. Handles a variety of sequence types: lists, padded and ragged.
      If the input is a 2d array, it is passed through unchanged.
      """
      return Model(
          f"with_array({layer.name})",
          forward,
          init=init,
          layers=[layer],
          attrs={"pad": pad},
          dims={
              name: layer.maybe_get_dim(name)
              for name in layer.dim_names
          },
      )
  
file_path: thinc/thinc/layers/with_array2d.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, Floats2d, List2d, Padded, Ragged
label_desc: Use image node_id 1 for calling a global function with example usage: with_array2d(layer, pad) and returns: Model