class_docstr: A utility attention mask class that allows one to:
      - Create a causal 4d mask
      - Create a causal 4d mask with slided window
      - Convert a 2d attention mask (batch_size, query_length) to a 4d attention mask (batch_size, 1, query_length,
        key_value_length) that can be multiplied with attention scores
  
  Examples:
  
  ```python
  >>> import torch
  >>> from transformers.modeling_attn_mask_utils import AttentionMaskConverter
  
  >>> converter = AttentionMaskConverter(True)
  >>> converter.to_4d(torch.tensor([[0, 0, 0, 1, 1]]), 5, key_value_length=5, dtype=torch.float32)
  tensor([[[[-3.4028e+38, -3.4028e+38, -3.4028e+38, -3.4028e+38, -3.4028e+38],
          [-3.4028e+38, -3.4028e+38, -3.4028e+38, -3.4028e+38, -3.4028e+38],
          [-3.4028e+38, -3.4028e+38, -3.4028e+38, -3.4028e+38, -3.4028e+38],
          [-3.4028e+38, -3.4028e+38, -3.4028e+38,  0.0000e+00, -3.4028e+38],
          [-3.4028e+38, -3.4028e+38, -3.4028e+38,  0.0000e+00,  0.0000e+00]]]])
  ```
  
  Parameters:
      is_causal (`bool`):
          Whether the attention mask should be a uni-directional (causal) or bi-directional mask.
  
      sliding_window (`int`, *optional*):
          Optionally, the sliding window masks can be created if `sliding_window` is defined to a positive integer.
class_docstr_tok: ["A","utility","attention","mask","class","that","allows","one","to",":","-","Create","a","causal","4d","mask","-","Create","a","causal","4d","mask","with","slided","window","-","Convert","a","2d","attention","mask","(","batch_size",",","query_length",")","to","a","4d","attention","mask","(","batch_size",",","1",",","query_length",",","key_value_length",")","that","can","be","multiplied","with","attention","scores","Examples",":","``","`","python",">",">",">","import","torch",">",">",">","from","transformers.modeling_attn_mask_utils","import","AttentionMaskConverter",">",">",">","converter","=","AttentionMaskConverter","(","True",")",">",">",">","converter.to_4d","(","torch.tensor","(","[","[","0",",","0",",","0",",","1",",","1","]","]",")",",","5",",","key_value_length=5",",","dtype=torch.float32",")","tensor","(","[","[","[","[","-3.4028e+38",",","-3.4028e+38",",","-3.4028e+38",",","-3.4028e+38",",","-3.4028e+38","]",",","[","-3.4028e+38",",","-3.4028e+38",",","-3.4028e+38",",","-3.4028e+38",",","-3.4028e+38","]",",","[","-3.4028e+38",",","-3.4028e+38",",","-3.4028e+38",",","-3.4028e+38",",","-3.4028e+38","]",",","[","-3.4028e+38",",","-3.4028e+38",",","-3.4028e+38",",","0.0000e+00",",","-3.4028e+38","]",",","[","-3.4028e+38",",","-3.4028e+38",",","-3.4028e+38",",","0.0000e+00",",","0.0000e+00","]","]","]","]",")","``","`","Parameters",":","is_causal","(","`","bool","`",")",":","Whether","the","attention","mask","should","be","a","uni-directional","(","causal",")","or","bi-directional","mask",".","sliding_window","(","`","int","`",",","*","optional","*",")",":","Optionally",",","the","sliding","window","masks","can","be","created","if","`","sliding_window","`","is","defined","to","a","positive","integer","."]
code: def __init__(
      self, is_causal: bool, sliding_window: Optional[int] = None
  ):
      self.is_causal = is_causal
      self.sliding_window = sliding_window
  
      if self.sliding_window is not None and self.sliding_window <= 0:
          raise ValueError(
              f"Make sure that when passing `sliding_window` that its value is a strictly positive integer, not `{self.sliding_window}`"
          )
  
file_path: transformers/src/transformers/modeling_attn_mask_utils.py
imports: from dataclasses import dataclass
  from typing import List, Optional, Tuple, Union
  import torch
label_desc: Use image node_id 1 to create a new AttentionMaskConverter object  with example: obj = AttentionMaskConverter(is_causal, sliding_window)