code: def build_transformer_block(
      net_part: str,
      block: Dict[str, Any],
      pw_layer_type: str,
      pw_activation_type: str,
  ) -> Union[EncoderLayer, TransformerDecoderLayer]:
      """Build function for transformer block.
  
      Args:
          net_part: Network part, either 'encoder' or 'decoder'.
          block: Transformer block parameters.
          pw_layer_type: Positionwise layer type.
          pw_activation_type: Positionwise activation type.
  
      Returns:
          : Function to create transformer (encoder or decoder) block.
  
      """
      d_hidden = block["d_hidden"]
  
      dropout_rate = block.get("dropout-rate", 0.0)
      pos_dropout_rate = block.get("pos-dropout-rate", 0.0)
      att_dropout_rate = block.get("att-dropout-rate", 0.0)
  
      if pw_layer_type != "linear":
          raise NotImplementedError(
              "Transformer block only supports linear pointwise layer."
          )
  
      if net_part == "encoder":
          transformer_layer_class = EncoderLayer
      elif net_part == "decoder":
          transformer_layer_class = TransformerDecoderLayer
  
      return lambda: transformer_layer_class(
          d_hidden,
          MultiHeadedAttention(
              block["heads"], d_hidden, att_dropout_rate
          ),
          PositionwiseFeedForward(
              d_hidden,
              block["d_ff"],
              pos_dropout_rate,
              get_activation(pw_activation_type),
          ),
          dropout_rate,
      )
  
imports: from typing import Any, Dict, List, Tuple, Union
  import torch
  from espnet.nets.pytorch_backend.conformer.convolution import ConvolutionModule
  from espnet.nets.pytorch_backend.conformer.encoder_layer import EncoderLayer
  from espnet.nets.pytorch_backend.nets_utils import get_activation
  from espnet.nets.pytorch_backend.transducer.conv1d_nets import CausalConv1d, Conv1d
  from espnet.nets.pytorch_backend.transducer.transformer_decoder_layer import TransformerDecoderLayer
  from espnet.nets.pytorch_backend.transducer.vgg2l import VGG2L
  from espnet.nets.pytorch_backend.transformer.attention import MultiHeadedAttention, RelPositionMultiHeadedAttention
  from espnet.nets.pytorch_backend.transformer.embedding import PositionalEncoding, RelPositionalEncoding, ScaledPositionalEncoding
  from espnet.nets.pytorch_backend.transformer.encoder_layer import EncoderLayer
  from espnet.nets.pytorch_backend.transformer.positionwise_feed_forward import PositionwiseFeedForward
  from espnet.nets.pytorch_backend.transformer.repeat import MultiSequential
  from espnet.nets.pytorch_backend.transformer.subsampling import Conv2dSubsampling
label_desc: Use image node_id 6 for calling a global function with example usage: build_transformer_block(net_part, block, pw_layer_type, pw_activation_type) and returns: function