code: def concat_pooling_forward(
      pooling: Model[Ragged, Floats2d], X: List[Ragged], is_train: bool
  ):
      xp = pooling.ops.xp
  
      datas = []
      lens = []
      doc_lens = []
      for X_doc_data in X:
          datas.append(X_doc_data.dataXd)
          lens.append(X_doc_data.lengths)
          doc_lens.append(len(X_doc_data.lengths))
  
      X_flat = Ragged(
          xp.concatenate(datas, axis=0), xp.concatenate(lens, axis=0)
      )
      Y_pooled, pooling_backprop = pooling(X_flat, is_train)
      Y = xp.split(Y_pooled, numpy.cumsum(doc_lens)[:-1])
  
      def backprop(dY):
          dY_pooled_flat = xp.concatenate(dY)
          dY_flat = pooling_backprop(dY_pooled_flat).dataXd
  
          dY = []
          for X_doc_data in X:
              doc_unpooled_len = X_doc_data.dataXd.shape[0]
              dY.append(
                  Ragged(dY_flat[:doc_unpooled_len], X_doc_data.lengths)
              )
              dY_flat = dY_flat[doc_unpooled_len:]
  
          return dY
  
      return Y, backprop
  
file_path: spacy-transformers/spacy_transformers/layers/trfs2arrays.py
imports: from typing import Callable, List, Optional, Tuple, cast
  import numpy
  from spacy.util import all_equal
  from transformers.file_utils import ModelOutput
  from transformers.modeling_outputs import BaseModelOutput
  from thinc.api import Model
  from thinc.types import Ragged, Floats2d
  from ..data_classes import TransformerData
  from ..align import apply_alignment
label_desc: Use image node_id 3 for calling a global function with example usage: concat_pooling_forward(pooling, X, is_train) and returns: Y,  backprop, dY