code: def _apply_dropout(att, dropout):
      if dropout is None:
          return att
  
      # Dropout chokes on sparse tensors
      if _has_cpp_library:
          if isinstance(att, SparseCS):
              values = att.values.clone()
              values = dropout(values)
              att = SparseCS.wrap(
                  att.shape,
                  values,
                  att.row_indices,
                  att.row_offsets,
                  att.column_indices,
                  att._transp_info,
              )
          elif att.is_sparse:
              att = att.coalesce()
              values = (
                  att.values().clone()
              )  # protect against in-place dropout
              values = dropout(values)
              att = torch.sparse_coo_tensor(
                  att.indices(), values, att.shape
              )
          else:
              # Simple dense case
              att = dropout(att)
  
          return att
  
      # Non optimized vanilla dropout
      att = dropout(att)
      return att
  
file_path: xformers/xformers/components/attention/core.py
imports: import logging
  import math
  from contextlib import nullcontext
  from functools import lru_cache
  from typing import Optional, Union
  import torch
  from xformers import _has_cpp_library, _is_triton_available
  from xformers.components.attention.attention_mask import AttentionMask
label_desc: Use image node_id 6 for calling a global function with example usage: _apply_dropout(att, dropout) and returns: att, att, att