code: def _local_1d_pattern(
      attn_size: int, window_size: int
  ) -> torch.Tensor:
      assert (
          window_size % 2 == 1
      ), "The window size is assumed to be odd (counts self-attention + 2 wings)"
      h_win_size = window_size // 2
  
      attn_shape = (attn_size, attn_size)
      full_attn = torch.ones(attn_shape, dtype=torch.bool)
  
      mask = torch.tril(full_attn, diagonal=h_win_size)
      mask &= ~torch.tril(full_attn, diagonal=-(h_win_size + 1))
      return mask
  
imports: import itertools
  import pytest
  import torch
  import xformers.components.attention.attention_patterns
  from xformers.components.attention.sparsity_config import BigBirdSparsityConfig, BSLongformerSparsityConfig, DenseSparsityConfig, FixedSparsityConfig, VariableSparsityConfig
label_desc: Use image node_id 1 for calling a global function with example usage: _local_1d_pattern(attn_size, window_size) and returns: mask