code: def LangIdentifierModelV2(
      ns: Sequence[int] = (1, 2, 3),
      embed_dim: int = 100,
      hidden_width: int = 512,
      dropout: Optional[float] = 0.1,
  ) -> Model[List[str], thinc.types.Floats2d]:
      """
      Build a language identification model inspired by Google's CLD3.
  
      Args:
          ns: Set of "n" for which character "n"-grams are extracted from input texts.
              If 1, only unigrams (single characters) are used; if [1, 2], then both
              unigrams and bigrams are used; and so on.
          embed_dim: Size of the vectors into which each set of ngrams are embedded.
          hidden_width: Width of the dense layer with Relu activation, just before
              the final prediction (Softmax) layer.
          dropout: Dropout rate to avoid overfitting.
  
      Returns:
          Thinc :class:`Model`.
      """
      with Model.define_operators({">>": chain}):
          model = (
              MultiCharNgramsEmbedding(
                  ns=list(ns),
                  max_chars=1000,
                  lower=True,
                  num_vectors=[2000 * n for n in ns],
                  embed_dims=embed_dim,
                  dropout=dropout,
              )
              >> thinc.layers.Relu(
                  nI=embed_dim * len(ns),
                  nO=hidden_width,
                  dropout=dropout,
              )
              >> thinc.layers.Softmax(nI=hidden_width)
          )
      return model
  
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 3 for calling a global function with example usage: LangIdentifierModelV2(ns, embed_dim, hidden_width, dropout) and returns: model