code: def _build_parametric_attention_with_residual_nonlinear(
      *,
      tok2vec: Model[List[Doc], List[Floats2d]],
      nonlinear_layer: Model[Floats2d, Floats2d],
      key_transform: Optional[Model[Floats2d, Floats2d]] = None,
  ) -> Model[List[Doc], Floats2d]:
      with Model.define_operators({">>": chain, "|": concatenate}):
          width = tok2vec.maybe_get_dim("nO")
          attention_layer = ParametricAttention_v2(
              nO=width, key_transform=key_transform
          )
          norm_layer = LayerNorm(nI=width)
          parametric_attention = (
              tok2vec
              >> list2ragged()
              >> attention_layer
              >> reduce_sum()
              >> residual(nonlinear_layer >> norm_layer >> Dropout(0.0))
          )
  
          parametric_attention.init = (
              _init_parametric_attention_with_residual_nonlinear
          )
  
          parametric_attention.set_ref("tok2vec", tok2vec)
          parametric_attention.set_ref(
              "attention_layer", attention_layer
          )
          parametric_attention.set_ref(
              "nonlinear_layer", nonlinear_layer
          )
          parametric_attention.set_ref("norm_layer", norm_layer)
  
          return parametric_attention
  
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 10 for calling a global function with example usage: _build_parametric_attention_with_residual_nonlinear() and returns: parametric_attention