code: def test_windowed_attention_shift() -> None:
      opts = get_opts()
  
      B, N, C = 2, 66, 8
      window_size = 16
      window_shift = 8
      t = WindowedTransformerEncoder(
          opts,
          embed_dim=C,
          ffn_latent_dim=4 * C,
          window_size=window_size,
          window_shift=window_shift,
      )
  
      # These are the boundaries at which the tensor values change.
      chunk_bounds = [0, 8, 24, 40, 56, 66]
      x = torch.empty([B, N, C]).fill_(float("-inf"))
      for start, end in zip(chunk_bounds[0:-1], chunk_bounds[1:]):
          prototype = torch.randn([C])
          x[:, start:end] = 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)
  
      # We expect @y[0] values to change at the boundaries defined by chunk_bounds.
      # The values are offset by the shift of 8 as well, since windowing will
      # occur at indices congruent to 8 mod 16.
      ensure_equal_in_range(y[0], 0, 8)
      ensure_equal_in_range(y[0], 8, 24)
      ensure_equal_in_range(y[0], 24, 40)
      ensure_equal_in_range(y[0], 40, 56)
      ensure_equal_in_range(y[0], 56, 63)
      # Masking at index 63 changes the values.
      ensure_equal_in_range(y[0], 63, 66)
  
      # We expect @y[0] values to change at the boundaries defined by chunk_bounds.
      ensure_equal_in_range(y[1], 0, 8)
      ensure_equal_in_range(y[1], 8, 24)
      ensure_equal_in_range(y[1], 24, 40)
      ensure_equal_in_range(y[1], 40, 56)
      ensure_equal_in_range(y[1], 56, 66)
  
imports: import pytest
  import torch
  import cvnets.modules
  from cvnets.modules import WindowedTransformerEncoder
  from tests.modules.test_transformer import ensure_equal_in_range, get_opts
label_desc: Use image node_id 3 for calling a global function with example usage: test_windowed_attention_shift() without return types