class_docstr: Head selection implemented in S2TTransformer
class_docstr_tok: ["Head","selection","implemented","in","S2TTransformer"]
code: def build_decoder(cls, args, task, 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 HeadSelectionTransformerDecoderScriptable(
              args, task.target_dictionary, embed_tokens
          )
      else:
          return TransformerDecoderScriptable(
              args, task.target_dictionary, embed_tokens
          )
  
imports: import logging
  from typing import Dict, List, Optional
  from pathlib import Path
  import torch.nn
  from torch import Tensor
  from fairseq import checkpoint_utils
  from fairseq.models import register_model, register_model_architecture
  from fairseq.utils import safe_hasattr
  from fairseq.models.speech_to_text.s2t_transformer import S2TTransformerModel, S2TTransformerEncoder, TransformerDecoderScriptable
  from fairseq.models.speech_to_text.s2t_transformer import base_architecture
  from ..modules.attn_head_selector import AttnHeadSelector
  from ..modules.head_selection_transformer_layer import HeadSelectionTransformerEncoderLayer
  from .head_selection_transformer import HeadSelectionTransformerDecoder
label_desc: Use image node_id 4 for calling the HeadSelectionS2TTransformerModel obj's underlying member method code with example usage: obj.build_decoder(cls, args, task, embed_tokens) and returns: HeadSelectionTransformerDecoderScriptable, TransformerDecoderScriptable