docstr: Returns a decoder based on architecture arch and kwargs
docstr_tok: ["Returns","a","decoder","based","on","architecture","arch","and","kwargs"]
code: def _build_encoder(self, arch, **kwargs):
      """
      Returns a decoder based on architecture arch and kwargs
      """
      # default non-bottleneck transformer encoder
      if (not arch) or (arch == "seq2seq"):
          encoder = self.encoder
      elif arch == "bridge":
          encoder = BridgeEncoder(
              num_layers=kwargs["num_layers"],
              hidden_size=kwargs["hidden_size"],
              inner_size=kwargs["inner_size"],
              num_attention_heads=kwargs["num_attention_heads"],
              attn_score_dropout=kwargs["attn_score_dropout"],
              attn_layer_dropout=kwargs["attn_layer_dropout"],
              ffn_dropout=kwargs["ffn_dropout"],
              hidden_act=kwargs["hidden_act"],
              mask_future=kwargs["mask_future"],
              pre_ln=kwargs["pre_ln"],
              pre_ln_final_layer_norm=kwargs["pre_ln_final_layer_norm"],
              hidden_steps=kwargs["hidden_steps"],
              hidden_blocks=kwargs["hidden_blocks"],
              hidden_init_method=kwargs["hidden_init_method"],
          )
      elif arch == "perceiver":
          encoder = PerceiverEncoder(
              num_layers=kwargs["num_layers"],
              hidden_size=kwargs["hidden_size"],
              inner_size=kwargs["inner_size"],
              num_attention_heads=kwargs["num_attention_heads"],
              attn_score_dropout=kwargs["attn_score_dropout"],
              attn_layer_dropout=kwargs["attn_layer_dropout"],
              ffn_dropout=kwargs["ffn_dropout"],
              hidden_act=kwargs["hidden_act"],
              mask_future=kwargs["mask_future"],
              pre_ln=kwargs["pre_ln"],
              pre_ln_final_layer_norm=kwargs["pre_ln_final_layer_norm"],
              hidden_steps=kwargs["hidden_steps"],
              hidden_blocks=kwargs["hidden_blocks"],
              hidden_init_method=kwargs["hidden_init_method"],
          )
      elif arch == "max_pool":
          encoder = PoolingEncoder(
              num_layers=kwargs["num_layers"],
              hidden_size=kwargs["hidden_size"],
              inner_size=kwargs["inner_size"],
              num_attention_heads=kwargs["num_attention_heads"],
              attn_score_dropout=kwargs["attn_score_dropout"],
              attn_layer_dropout=kwargs["attn_layer_dropout"],
              ffn_dropout=kwargs["ffn_dropout"],
              hidden_act=kwargs["hidden_act"],
              mask_future=kwargs["mask_future"],
              pre_ln=kwargs["pre_ln"],
              pre_ln_final_layer_norm=kwargs["pre_ln_final_layer_norm"],
              hidden_steps=kwargs["hidden_steps"],
              hidden_blocks=kwargs["hidden_blocks"],
              hidden_init_method=kwargs["hidden_init_method"],
              pooling_type="max",
          )
      elif arch == "avg_pool":
          encoder = PoolingEncoder(
              num_layers=kwargs["num_layers"],
              hidden_size=kwargs["hidden_size"],
              inner_size=kwargs["inner_size"],
              num_attention_heads=kwargs["num_attention_heads"],
              attn_score_dropout=kwargs["attn_score_dropout"],
              attn_layer_dropout=kwargs["attn_layer_dropout"],
              ffn_dropout=kwargs["ffn_dropout"],
              hidden_act=kwargs["hidden_act"],
              mask_future=kwargs["mask_future"],
              pre_ln=kwargs["pre_ln"],
              pre_ln_final_layer_norm=kwargs["pre_ln_final_layer_norm"],
              hidden_steps=kwargs["hidden_steps"],
              hidden_blocks=kwargs["hidden_blocks"],
              hidden_init_method=kwargs["hidden_init_method"],
              pooling_type="avg",
          )
      else:
          raise ValueError(
              f"Unknown arch = {self.arch}, supported arch = {self.supported_arch}"
          )
  
      return encoder
  
imports: from dataclasses import dataclass
  from typing import Dict, Optional
  from nemo.collections.asr.modules.transformer.bridge_encoders import BridgeEncoder
  from nemo.collections.asr.modules.transformer.perceiver_encoders import PerceiverEncoder
  from nemo.collections.asr.modules.transformer.reduction_encoders import PoolingEncoder
  from nemo.collections.asr.modules.transformer.transformer import NeMoTransformerConfig, TransformerDecoderNM, TransformerEncoderNM
  from nemo.core.classes.common import typecheck
  from nemo.core.neural_types import MaskType, NeuralType
  from nemo.core.neural_types.elements import BoolType
label_desc: Use image node_id 2 for calling the TransformerBottleneckEncoderNM obj's underlying member method code with example usage: obj._build_encoder(arch) and returns: encoder