code: def _calculate_scale(query, scale):
      softmax_scale = (
          scale
          if scale is not None
          else math.sqrt(1.0 / query.size(-1))
      )
      return softmax_scale
  
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 16 for calling a global function with example usage: _calculate_scale(query, scale) and returns: softmax_scale