class_docstr: ## Multi-DConv-Head Attention (MDHA)
  
  We extend our original implementation of [Multi-Head Attention](../mha.html#MHA)
  and add the spatial depth-wise convolution to query, key and value projections.
      
class_docstr_tok: ["#","#","Multi-DConv-Head","Attention","(","MDHA",")","We","extend","our","original","implementation","of","[","Multi-Head","Attention","]","(","..","\/mha.html","#","MHA",")","and","add","the","spatial","depth-wise","convolution","to","query",",","key","and","value","projections","."]
code: def __init__(
      self, heads: int, d_model: int, dropout_prob: float = 0.1
  ):
      super().__init__(heads, d_model, dropout_prob)
  
      # [Multi-Head Attention](../mha.html#MHA) will create query, key and value projection modules
      # `self.query`, `self.key`, and `self.value`.
      #
      # We combine a spatial depth-wise convolution layer to each of them and replace
      # `self.query`, `self.key`, and `self.value`.
      self.query = nn.Sequential(
          self.query, SpatialDepthWiseConvolution(self.d_k)
      )
      self.key = nn.Sequential(
          self.key, SpatialDepthWiseConvolution(self.d_k)
      )
      self.value = nn.Sequential(
          self.value, SpatialDepthWiseConvolution(self.d_k)
      )
  
file_path: annotated_deep_learning_paper_implementations/labml_nn/transformers/primer_ez/efficient.py
imports: import math
  import torch
  from torch import nn
  from labml_helpers.module import Module
  from labml_nn.transformers import MultiHeadAttention
label_desc: Use image node_id 1 to create a new MultiDConvHeadAttention object from inherited base classes: MultiHeadAttention with example: obj = MultiDConvHeadAttention(heads, d_model, dropout_prob)