class_docstr: The class is a wrapper of MultiHead Attention for torch.nn.MultiHeadAttention.
  
  Reference: https://pytorch.org/docs/stable/nn.html
  
  Arguments
  ----------
  num_heads : int
      parallel attention heads.
  dropout : float
      a Dropout layer on attn_output_weights (default: 0.0).
  bias : bool
      add bias as module parameter (default: True).
  add_bias_kv : bool
      add bias to the key and value sequences at dim=0.
  add_zero_attn : bool
      add a new batch of zeros to the key and value sequences at dim=1.
  kdim : int
      total number of features in key (default: None).
  vdim : int
      total number of features in value (default: None).
  
  Example
  -------
  >>> inputs = torch.rand([8, 60, 512])
  >>> net = MultiheadAttention(nhead=8, d_model=inputs.shape[-1])
  >>> outputs, attn = net(inputs, inputs, inputs)
  >>> outputs.shape
  torch.Size([8, 60, 512])
code: def __init__(
      self,
      nhead,
      d_model,
      dropout=0.0,
      bias=True,
      add_bias_kv=False,
      add_zero_attn=False,
      kdim=None,
      vdim=None,
  ):
      super().__init__()
  
      self.att = nn.MultiheadAttention(
          embed_dim=d_model,
          num_heads=nhead,
          dropout=dropout,
          bias=bias,
          add_bias_kv=add_bias_kv,
          add_zero_attn=add_zero_attn,
          kdim=kdim,
          vdim=vdim,
      )
  
imports: import torch
  import logging
  import torch.nn
  import numpy
  from typing import Optional
  from speechbrain.dataio.dataio import length_to_mask
  import torch.nn.functional
  import math
label_desc: Use image node_id 1 to create a new MultiheadAttention object from inherited base classes: nn with example: obj = MultiheadAttention(nhead, d_model, dropout, bias, add_bias_kv, add_zero_attn, kdim, vdim)