code: def __init__(
      self,
      args,
      dictionary,
      embed_tokens,
      no_encoder_attn=False,
      output_projection=None,
  ):
      self.num_tasks = args.decoder_tasks
      self.num_layers = args.decoder_layers
      self.total_num_heads = args.total_decoder_attention_heads
      self.num_heads = args.decoder_attention_heads
      self.select_strategy = args.attn_head_select_strategy
      super().__init__(
          args,
          dictionary,
          embed_tokens,
          no_encoder_attn=no_encoder_attn,
          output_projection=output_projection,
      )
      self.self_attn_head_selector = None
      self.enc_attn_head_selector = None
      if (
          safe_hasattr(args, "decoder_self_attn_head_select")
          and args.decoder_self_attn_head_select
      ):
          self.self_attn_head_selector = AttnHeadSelector(
              self.num_tasks,
              self.num_layers,
              self.total_num_heads,
              self.num_heads,
              self.select_strategy,
          )
      if (
          safe_hasattr(args, "dec_enc_attn_head_select")
          and args.dec_enc_attn_head_select
      ):
          self.enc_attn_head_selector = AttnHeadSelector(
              self.num_tasks,
              self.num_layers,
              self.total_num_heads,
              self.num_heads,
              self.select_strategy,
          )
      self.task_ids = None
      self.layers = nn.ModuleList(
          [
              self.build_head_selection_decoder_layer(
                  args, no_encoder_attn, idx
              )
              for idx in range(args.decoder_layers)
          ]
      )
  
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 1 to create a new HeadSelectionTransformerDecoder object from inherited base classes: TransformerDecoder with example: obj = HeadSelectionTransformerDecoder(args, dictionary, embed_tokens, no_encoder_attn, output_projection)