code: def build_decoder(cls, args, tgt_dict, embed_tokens):
      if (
          safe_hasattr(args, "decoder_self_attn_head_select")
          and args.decoder_self_attn_head_select
      ) or (
          safe_hasattr(args, "dec_enc_attn_head_select")
          and args.dec_enc_attn_head_select
      ):
          return HeadSelectionTransformerDecoder(
              args, tgt_dict, embed_tokens
          )
      else:
          return TransformerDecoder(args, tgt_dict, embed_tokens)
  
imports: from typing import Any, List, Dict, Optional
  import torch
  import torch.nn
  from torch import Tensor
  from fairseq.utils import safe_hasattr
  from fairseq.models.transformer import TransformerModel, TransformerEncoder, TransformerDecoder
  from ..modules.attn_head_selector import AttnHeadSelector
  from ..modules.head_selection_transformer_layer import HeadSelectionTransformerEncoderLayer, HeadSelectionTransformerDecoderLayer
label_desc: Use image node_id 4 for calling the HeadSelectionTransformerModel obj's underlying member method code with example usage: obj.build_decoder(cls, args, tgt_dict, embed_tokens) and returns: HeadSelectionTransformerDecoder, TransformerDecoder