code: def get_dropout_fraction(
      dropout_mask,
      query_padding_mask=None,
      key_padding_mask=None,
      causal=False,
      window_size=(-1, -1),  # -1 means infinite window size
  ):
      """
      dropout_mask: (batch_size, nheads, seqlen_q, seqlen_k), bool. True means keep, False means drop.
      query_padding_mask: (batch_size, seqlen_q)
      key_padding_mask: (batch_size, seqlen_k)
      """
      if causal:
          window_size = (window_size[0], 0)
      batch_size, nheads, seqlen_q, seqlen_k = dropout_mask.shape
      dropped = ~dropout_mask
      valid = torch.ones_like(dropout_mask)
      if query_padding_mask is not None:
          dropped.masked_fill_(
              rearrange(~query_padding_mask, "b s -> b 1 s 1"), False
          )
          valid.masked_fill_(
              rearrange(~query_padding_mask, "b s -> b 1 s 1"), False
          )
      if key_padding_mask is not None:
          dropped.masked_fill_(
              rearrange(~key_padding_mask, "b s -> b 1 1 s"), False
          )
          valid.masked_fill_(
              rearrange(~key_padding_mask, "b s -> b 1 1 s"), False
          )
      if window_size[0] >= 0 or window_size[1] >= 0:
          local_mask = construct_local_mask(
              seqlen_q,
              seqlen_k,
              window_size,
              query_padding_mask,
              key_padding_mask,
              dropout_mask.device,
          )
          dropped.masked_fill_(local_mask, False)
          valid.masked_fill_(local_mask, False)
      dropped_total = dropped.sum()
      return dropped.sum() / valid.sum()
  
imports: import math
  import pytest
  import torch
  import torch.nn.functional
  from einops import rearrange, repeat
  from flash_attn import flash_attn_func, flash_attn_kvpacked_func, flash_attn_qkvpacked_func, flash_attn_varlen_func, flash_attn_varlen_kvpacked_func, flash_attn_varlen_qkvpacked_func, flash_attn_with_kvcache
  from flash_attn.bert_padding import pad_input, unpad_input
  from flash_attn.flash_attn_interface import _get_block_size_n
  from flash_attn.layers.rotary import apply_rotary_emb
label_desc: Use image node_id 12 for calling a global function with example usage: get_dropout_fraction(dropout_mask, query_padding_mask, key_padding_mask, causal, window_size) and returns: unknown