code: def _validate_sdpa_input(
      query: torch.Tensor,
      key: torch.Tensor,
      value: torch.Tensor,
      attn_mask: Optional[torch.Tensor] = None,
      dropout_p=0.0,
      is_causal=False,
      scale=None,
  ):
      if (
          not isinstance(query, NestedTensor)
          or not isinstance(key, NestedTensor)
          or not isinstance(value, NestedTensor)
      ):
          raise ValueError(
              f"Expected query, key, and value to be nested tensors, "
              f"but got query.is_nested: {query.is_nested}, key.is_nested: {key.is_nested}, "
              f"and value.is_nested: {value.is_nested} instead."
          )
      if query.dtype != key.dtype or query.dtype != value.dtype:
          raise ValueError(
              f"Expected query, key, and value to have the same dtype, "
              f"but got query.dtype: {query.dtype}, key.dtype: {key.dtype}, "
              f"and value.dtype: {value.dtype} instead."
          )
      if query.device != key.device or query.device != value.device:
          raise ValueError(
              f"Expected query, key, and value to have the same device type, "
              f"but got query.device: {query.device}, key.device: {key.device}, "
              f"and value.device: {value.device} instead."
          )
      if query.dim() < 2 or key.dim() < 2 or value.dim() < 2:
          raise ValueError(
              f"Expected query, key, and value to all be  at least 2 dimensional, but got query.dim: "
              f"{query.dim()}, key.dim: {key.dim()} and value.dim: {value.dim()} instead."
          )
      if (
          query._ragged_idx != key._ragged_idx
          or query._ragged_idx != value._ragged_idx
      ):
          raise ValueError(
              f"Expected query, key, and value to all be ragged on the same dimension, but got ragged "
              f"dims {query._ragged_idx}, {key._ragged_idx}, and {value._ragged_idx}, respectively."
          )
      if attn_mask is not None:
          # TODO: Figure out whether masks are actually supported for this layout or not
          raise ValueError("Masks are not yet supported!")
          if (
              attn_mask.dtype != torch.bool
              and attn_mask.dtype != query.dtype
          ):
              raise ValueError(
                  f"Expected attn_mask dtype to be bool or to match query dtype, but got attn_mask.dtype: "
                  f"{attn_mask.dtype}, and query.dtype: {query.dtype} instead."
              )
  
imports: import logging
  import math
  from typing import Optional, Tuple
  import torch
  import torch.nn
  import torch.nn.functional
  from torch.backends.cuda import can_use_efficient_attention, can_use_flash_attention, flash_sdp_enabled, math_sdp_enabled, mem_efficient_sdp_enabled, SDPAParams, SDPBackend
  from .nested_tensor import buffer_from_jagged, NestedTensor, ViewNestedFromBuffer
label_desc: Use image node_id 1 for calling a global function with example usage: _validate_sdpa_input(query, key, value, attn_mask, dropout_p, is_causal, scale) without return types