code: def text_to_char_ngrams(
      n: int,
      max_chars: int,
      lower: bool,
  ) -> Model[List[str], List[List[str]]]:
      """
      Custom data type transfer thinc layer that transforms a sequence of text strings
      into a sequence of sequence of character ngram strings. Like this::
  
          ["a short text.", "another text."] => [["a ", " s", "sh", "ho", ...], ...]
  
      Args:
          n: Number of adjacent characters to combine into an ngram.
          max_chars: Max number of characters from the start of the text to transform
              into character ngrams.
          lower: If True, lowercase text before extracting character ngrams; otherwise,
              leave text casing as-is.
      """
  
      def forward(
          model: Model, texts: List[str], is_train: bool
      ) -> Tuple[List[List[str]], Callable]:
          if lower is True:
              texts = [text[:max_chars].lower() for text in texts]
          else:
              texts = [text[:max_chars] for text in texts]
          if n == 1:
              char_ngs = [list(text) for text in texts]
          else:
              char_ngs = [
                  [text[i : i + n] for i in range(len(text) - n + 1)]
                  for text in texts
              ]
  
          def backprop(dY):
              return []
  
          return (char_ngs, backprop)
  
      return Model(
          "texts_to_char_ngrams",
          forward,
          attrs={"n": n, "max_chars": max_chars, "lower": lower},
      )
  
file_path: textacy/src/textacy/lang_id/models.py
imports: from __future__ import annotations
  from typing import Callable, List, Optional, Sequence, Tuple
  import numpy
  import thinc
  import thinc.layers
  import thinc.types
  from cytoolz import itertoolz
  from thinc.api import Model, chain, concatenate
label_desc: Use image node_id 6 for calling a global function with example usage: text_to_char_ngrams(n, max_chars, lower) and returns: Model, char_ngs,  backprop, list