class_docstr: An implementation of the spatial attention mechanism.
  For details see this paper: `"GMAN: A Graph Multi-Attention Network for Traffic Prediction."
  <https://arxiv.org/pdf/1911.08415.pdf>`_
  
  Args:
      K (int) : Number of attention heads.
      d (int) : Dimension of each attention head outputs.
      bn_decay (float): Batch normalization momentum.
docstr: Making a forward pass of the spatial attention mechanism.
  
  Arg types:
      * **X** (PyTorch Float Tensor) - Input sequence, with shape (batch_size, num_step, num_nodes, K*d).
      * **STE** (Pytorch Float Tensor) - Spatial-temporal embedding, with shape (batch_size, num_step, num_nodes, K*d).
  
  Return types:
      * **X** (PyTorch Float Tensor) - Spatial attention scores, with shape (batch_size, num_step, num_nodes, K*d).
docstr_tok: ["Making","a","forward","pass","of","the","spatial","attention","mechanism",".","Arg","types",":","*","*","*","X","*","*","(","PyTorch","Float","Tensor",")","-","Input","sequence",",","with","shape","(","batch_size",",","num_step",",","num_nodes",",","K","*","d",")",".","*","*","*","STE","*","*","(","Pytorch","Float","Tensor",")","-","Spatial-temporal","embedding",",","with","shape","(","batch_size",",","num_step",",","num_nodes",",","K","*","d",")",".","Return","types",":","*","*","*","X","*","*","(","PyTorch","Float","Tensor",")","-","Spatial","attention","scores",",","with","shape","(","batch_size",",","num_step",",","num_nodes",",","K","*","d",")","."]
code: def forward(
      self, X: torch.FloatTensor, STE: torch.FloatTensor
  ) -> torch.FloatTensor:
      """
      Making a forward pass of the spatial attention mechanism.
  
      Arg types:
          * **X** (PyTorch Float Tensor) - Input sequence, with shape (batch_size, num_step, num_nodes, K*d).
          * **STE** (Pytorch Float Tensor) - Spatial-temporal embedding, with shape (batch_size, num_step, num_nodes, K*d).
  
      Return types:
          * **X** (PyTorch Float Tensor) - Spatial attention scores, with shape (batch_size, num_step, num_nodes, K*d).
      """
      batch_size = X.shape[0]
      X = torch.cat((X, STE), dim=-1)
      query = self._fully_connected_q(X)
      key = self._fully_connected_k(X)
      value = self._fully_connected_v(X)
      query = torch.cat(torch.split(query, self._K, dim=-1), dim=0)
      key = torch.cat(torch.split(key, self._K, dim=-1), dim=0)
      value = torch.cat(torch.split(value, self._K, dim=-1), dim=0)
      attention = torch.matmul(query, key.transpose(2, 3))
      attention /= self._d**0.5
      attention = F.softmax(attention, dim=-1)
      X = torch.matmul(attention, value)
      X = torch.cat(torch.split(X, batch_size, dim=0), dim=-1)
      X = self._fully_connected(X)
      del query, key, value, attention
      return X
  
imports: import math
  from typing import Union, Callable, Optional
  import torch
  import torch.nn
  import torch.nn.functional
label_desc: Use image node_id 2 for calling the SpatialAttention obj's underlying member method code with example usage: obj.forward(X, STE) and returns: X