code: def _build_bow_text_classifier(
      exclusive_classes: bool,
      ngram_size: int,
      no_output_layer: bool,
      sparse_linear: Model[Tuple[ArrayXd, ArrayXd, ArrayXd], ArrayXd],
      nO: Optional[int] = None,
  ) -> Model[List[Doc], Floats2d]:
      fill_defaults = {"b": 0, "W": 0}
      with Model.define_operators({">>": chain}):
          output_layer = None
          if not no_output_layer:
              fill_defaults["b"] = NEG_VALUE
              output_layer = (
                  softmax_activation()
                  if exclusive_classes
                  else Logistic()
              )
          resizable_layer: Model[Floats2d, Floats2d] = resizable(
              sparse_linear,
              resize_layer=partial(
                  resize_linear_weighted, fill_defaults=fill_defaults
              ),
          )
          model = (
              extract_ngrams(ngram_size, attr=ORTH) >> resizable_layer
          )
          model = with_cpu(model, model.ops)
          if output_layer:
              model = model >> with_cpu(output_layer, output_layer.ops)
      if nO is not None:
          model.set_dim("nO", cast(int, nO))
      model.set_ref("output_layer", sparse_linear)
      model.attrs["multi_label"] = not exclusive_classes
      model.attrs["resize_output"] = partial(
          resize_and_set_ref, resizable_layer=resizable_layer
      )
      return model
  
imports: from functools import partial
  from typing import List, Optional, Tuple, cast
  from thinc.api import Dropout, Gelu, LayerNorm, Linear, Logistic, Maxout, Model, ParametricAttention, ParametricAttention_v2, Relu, Softmax, SparseLinear, SparseLinear_v2, chain, clone, concatenate, list2ragged, reduce_first, reduce_last, reduce_max, reduce_mean, reduce_sum, residual, resizable, softmax_activation, with_cpu
  from thinc.layers.chain import init
  from thinc.layers.resizable import resize_linear_weighted, resize_model
  from thinc.types import ArrayXd, Floats2d
  from ...attrs import ORTH
  from ...errors import Errors
  from ...tokens import Doc
  from ...util import registry
  from ..extract_ngrams import extract_ngrams
  from ..staticvectors import StaticVectors
  from .tok2vec import get_tok2vec_width
label_desc: Use image node_id 5 for calling a global function with example usage: _build_bow_text_classifier(exclusive_classes, ngram_size, no_output_layer, sparse_linear, nO) and returns: model