code: def _dispatch_fw_priority_list(
      inp: Inputs, needs_gradient: bool
  ) -> Sequence[Type[AttentionFwOpBase]]:
      priority_list_ops = deque(
          [
              flash.FwOp,
              triton.FwOp,
              cutlass.FwOp,
              small_k.FwOp,
          ]
      )
      if _is_cutlass_fwd_faster_than_flash(inp):
          priority_list_ops.remove(cutlass.FwOp)
          priority_list_ops.appendleft(cutlass.FwOp)
      if _is_triton_fwd_fastest(inp):
          priority_list_ops.remove(triton.FwOp)
          priority_list_ops.appendleft(triton.FwOp)
      if not needs_gradient:
          mqa_or_gqa = (
              inp.key.ndim > 3
              and inp.key.stride(-2) == 0
              and inp.key.shape[-2] > 1
          )
          if not mqa_or_gqa:
              # With multiquery, cutlass is sometimes faster than decoder
              # but it's not currently clear when.
              priority_list_ops.appendleft(decoder.FwOp)
          # Split-KV is useful with MQA
          # for short Q-seqlen / long K-seqlen
          if (
              mqa_or_gqa
              and inp.query.shape[1] <= 32
              and inp.key.shape[1] >= 256
          ):
              parallelism_BH = 0  # BMK
              if inp.query.ndim == 3:
                  parallelism_BH = inp.query.shape[0]
              elif inp.query.ndim == 4:  # BMHK
                  parallelism_BH = (
                      inp.query.shape[0] * inp.query.shape[2]
                  )
              elif inp.query.ndim == 5:  # BMGHK
                  parallelism_BH = (
                      inp.query.shape[0] * inp.query.shape[2]
                  )
              if parallelism_BH > 0 and parallelism_BH < 64:
                  priority_list_ops.appendleft(triton_splitk.FwOp)
                  # Without variable seqlen flash is fastest
                  if not isinstance(
                      inp.attn_bias, attn_bias.BlockDiagonalMask
                  ):
                      priority_list_ops.remove(flash.FwOp)
                      priority_list_ops.appendleft(flash.FwOp)
  
      return priority_list_ops
  
file_path: xformers/xformers/ops/fmha/dispatch.py
imports: import textwrap
  from collections import deque
  from typing import List, Sequence, Type, TypeVar
  from .None import attn_bias, cutlass, decoder, flash, small_k, triton, triton_splitk
  from .common import AttentionBwOpBase, AttentionFwOpBase, Inputs
label_desc: Use image node_id 7 for calling a global function with example usage: _dispatch_fw_priority_list(inp, needs_gradient) and returns: priority_list_ops