code: def test_masked_attention() -> None:
      opts = get_opts()
  
      B, N, C = 2, 64 + 2, 8
      t = TransformerEncoder(opts, embed_dim=C, ffn_latent_dim=4 * C)
      prototype = torch.randn([C])
      x = torch.ones([B, N, C])
      x[:, :] = prototype
  
      key_padding_mask = torch.zeros([B, N])
      key_padding_mask[0, 63:] = float("-inf")
      # Mask the @x values at the masked positions.
      x[0, 63:] = 0
  
      y = t(x, key_padding_mask=key_padding_mask)
  
      prototype = y[0, 0]
      assert torch.all(prototype == y[0, :63])
      assert torch.all(prototype != y[0, 63:])
  
      prototype = y[1, 0]
      assert torch.all(prototype == y[1, :])
  
imports: import argparse
  import torch
  from cvnets.modules import TransformerEncoder
label_desc: Use image node_id 3 for calling a global function with example usage: test_masked_attention() without return types