code: def masked_concat_pool(
      output: Tensor,  # Output of sentence encoder
      mask: Tensor,  # Boolean mask as returned by sentence encoder
      bptt: int,  # Backpropagation through time
  ) -> Tensor:  # Concatenation of [last_hidden, max_pool, avg_pool]
      "Pool `MultiBatchEncoder` outputs into one vector [last_hidden, max_pool, avg_pool]"
      lens = output.shape[1] - mask.long().sum(dim=1)
      last_lens = mask[:, -bptt:].long().sum(dim=1)
      avg_pool = output.masked_fill(mask[:, :, None], 0).sum(dim=1)
      avg_pool.div_(lens.type(avg_pool.dtype)[:, None])
      max_pool = output.masked_fill(
          mask[:, :, None], -float("inf")
      ).max(dim=1)[0]
      x = torch.cat(
          [
              output[torch.arange(0, output.size(0)), -last_lens - 1],
              max_pool,
              avg_pool,
          ],
          1,
      )  # Concat pooling.
      return x
  
imports: from __future__ import annotations
  from ...data.all import *
  from ..core import *
  from .awdlstm import *
label_desc: Use image node_id 3 for calling a global function with example usage: masked_concat_pool(output, mask, bptt) and returns: x