class_docstr: Builds modules of a LLaMA model as described in
  :cite:t:`https://doi.org/10.48550/arxiv.2302.13971` and
  :cite:t:`https://doi.org/10.48550/arXiv.2307.09288`.
  
  To tweak the architecture, you can derive from this class and override the
  corresponding methods.
class_docstr_tok: ["Builds","modules","of","a","LLaMA","model","as","described","in",":","cite",":","t",":","`","https",":","\/\/doi.org\/10.48550\/arxiv.2302.13971","`","and",":","cite",":","t",":","`","https",":","\/\/doi.org\/10.48550\/arXiv.2307.09288","`",".","To","tweak","the","architecture",",","you","can","derive","from","this","class","and","override","the","corresponding","methods","."]
docstr: Build a Transformer multi-head attention layer.
docstr_tok: ["Build","a","Transformer","multi-head","attention","layer","."]
code: def build_attention(
      self, num_heads: int, num_key_value_heads: int
  ) -> MultiheadAttention:
      """Build a Transformer multi-head attention layer."""
      sdpa = create_default_sdpa(attn_dropout_p=self.config.dropout_p)
  
      if self.pos_encoder is None:
          self.pos_encoder = RotaryEncoder(
              self.config.model_dim // num_heads,
              self.config.max_seq_len,
              device=self.device,
          )
  
      return StandardMultiheadAttention(
          self.config.model_dim,
          num_heads,
          num_key_value_heads=num_key_value_heads,
          sdpa=sdpa,
          pos_encoder=self.pos_encoder,
          bias=False,
          device=self.device,
          dtype=self.dtype,
      )
  
imports: from dataclasses import dataclass
  from typing import Optional
  from fairseq2.data import VocabularyInfo
  from fairseq2.models.transformer import TransformerDecoderModel, TransformerEmbeddingFrontend, TransformerFrontend, init_final_projection
  from fairseq2.models.utils import ArchitectureRegistry
  from fairseq2.nn.embedding import StandardEmbedding
  from fairseq2.nn.lora import LoRAConfig
  from fairseq2.nn.normalization import LayerNorm, RMSNorm
  from fairseq2.nn.position_encoder import RotaryEncoder
  from fairseq2.nn.projection import Linear
  from fairseq2.nn.transformer import FeedForwardNetwork, GLUFeedForwardNetwork, MultiheadAttention, StandardMultiheadAttention, StandardTransformerDecoder, StandardTransformerDecoderLayer, TransformerDecoder, TransformerDecoderLayer, TransformerNormOrder, create_default_sdpa
  from fairseq2.typing import DataType, Device
label_desc: Use image node_id 6 for calling the LLaMABuilder obj's underlying member method code with example usage: obj.build_attention(num_heads, num_key_value_heads) and returns: StandardMultiheadAttention