original_docstring: 
      Instantiates decoder architecture for the U-Net segmmantation model.
      Args:
          num_classes: number of the segmentation classes.
          decoder_input: decoder input or encoder model output.
          skip_connection_layers: encoder block outputs before pooling.
                                  They will serve as skip connection inputs
                                  for the decoder blocks.
          encoder_filters: (optional) a list containing filter sizes for each 
                            encoder block. Default to [32, 64, 128, 256].
          decoder_type: (optional) one of 'transpose' (to use Conv2DTanspose
                        operation for upsampling operation) or 'upsampling'
                        (to use UpSampling2D operation for upsampling operation).
                        Default to upsampling.
          num_blocks: (optional) number of encoder/decoder blocks to use. 
                      Default to 5.
          decoder_filters: (optional) a list containing filter sizes for each 
                            decoder block. Default to [512, 256, 128, 64, 32].
          num_decoder_block_conv_layers: (optional) number of convolution layers 
                                          for each decoder block (i.e. number of 
                                          Conv2D layers after upsampling layers). 
                                          Default to 1.
          decoder_activation: (optional) decoder activation name or function.
          decoder_use_skip_connection: (optional) one of True (to use skip
                                       connections) or False (not to use skip
                                       connections). Default to True.
          decoder_use_batchnorm: (optional) boolean to specify whether to
                                  use BatchNormalization or not. Default to True.
          decoder_dropout_rate: (optional) dropout rate. Float between 0 and 1.
          output_activation: (optional) activation for output layer.
                              Default is either 'sigmoid' or 'softmax' based on
                              the value of the 'num_classes' argument.
      Returns:
          x: decoder output
      
docstring: Instantiates decoder architecture for the U-Net segmmantation model.
docstring_tokens: Instantiates decoder architecture for the U - Net segmmantation model .
code: def unet_decoder(num_classes,
                   decoder_input,
                   skip_connection_layers,
                   encoder_filters=[32, 64, 128, 256, 512],
                   decoder_type='upsampling',
                   num_blocks=5,
                   num_decoder_block_conv_layers=1,
                   decoder_activation=None,
                   decoder_use_skip_connection=True,
                   decoder_use_batchnorm=True,
                   decoder_dropout_rate=0,
                   output_activation=None):
      
      """
      Instantiates decoder architecture for the U-Net segmmantation model.
      Args:
          num_classes: number of the segmentation classes.
          decoder_input: decoder input or encoder model output.
          skip_connection_layers: encoder block outputs before pooling.
                                  They will serve as skip connection inputs
                                  for the decoder blocks.
          encoder_filters: (optional) a list containing filter sizes for each 
                            encoder block. Default to [32, 64, 128, 256].
          decoder_type: (optional) one of 'transpose' (to use Conv2DTanspose
                        operation for upsampling operation) or 'upsampling'
                        (to use UpSampling2D operation for upsampling operation).
                        Default to upsampling.
          num_blocks: (optional) number of encoder/decoder blocks to use. 
                      Default to 5.
          decoder_filters: (optional) a list containing filter sizes for each 
                            decoder block. Default to [512, 256, 128, 64, 32].
          num_decoder_block_conv_layers: (optional) number of convolution layers 
                                          for each decoder block (i.e. number of 
                                          Conv2D layers after upsampling layers). 
                                          Default to 1.
          decoder_activation: (optional) decoder activation name or function.
          decoder_use_skip_connection: (optional) one of True (to use skip
                                       connections) or False (not to use skip
                                       connections). Default to True.
          decoder_use_batchnorm: (optional) boolean to specify whether to
                                  use BatchNormalization or not. Default to True.
          decoder_dropout_rate: (optional) dropout rate. Float between 0 and 1.
          output_activation: (optional) activation for output layer.
                              Default is either 'sigmoid' or 'softmax' based on
                              the value of the 'num_classes' argument.
      Returns:
          x: decoder output
      """
      #--------------------------------------------------------------------------#
      # Validate and preprocess arguments
      #--------------------------------------------------------------------------#
      # 1. number of classes specified
      if num_classes < 2:
          raise ValueError("The `num_classes` argument cannot be less than 2.")
      elif not (isinstance(num_classes, int)):
          raise ValueError("The `num_classes` argumentcan only be an integer.")
  
      # 2. num_blocks
      if not isinstance(num_blocks, int):
          raise ValueError('The `num_blocks` argument should be integer')
      elif num_blocks <= 0:
          raise ValueError('The `num_blocks` argument cannot be less '
                           'than or equal to zero')
  
      # 3. num_decoder_block_conv_layers
      if not isinstance(num_decoder_block_conv_layers, int):
          raise ValueError('The `num_decoder_block_conv_layers` argument should '
                           'be integer')
      elif num_decoder_block_conv_layers <= 0:
          raise ValueError('The `num_decoder_block_conv_layers` argument cannot '
                           'be less than or equal to zero')
  
      # 4. decoder_activation=None
      if decoder_activation == None:
          decoder_activation = 'relu'
  
      # 5. decoder_use_batchnorm=False,
      if not isinstance(decoder_use_batchnorm, bool):
          raise ValueError("The `decoder_use_batchnorm` argument should "
                           "either be True or False.")
  
      # 6. decoder_dropout_rate=0
      if not (isinstance(decoder_dropout_rate, int) or 
              isinstance(decoder_dropout_rate, float)):
          raise ValueError('The `decoder_use_dropout` argument should be'
                           ' an integer or float between 0 and 1')
      elif decoder_dropout_rate < 0 or decoder_dropout_rate > 1:
          raise ValueError("The `decoder_use_dropout` argument cannot be "
                           "less than 0 or greater than 1.")
  
      # 7. output activation
      if output_activation == None:
          if num_classes == 2:
              output_activation = 'sigmoid'
          else:
              output_activation = 'softmax'
  
      #--------------------------------------------------------------------------#
      # Build the decoder blocks from the arguments specified
      #--------------------------------------------------------------------------#
      ## Decoder Blocks
      encoder_filters = encoder_filters[0:num_blocks]
      skip_connection_layers = skip_connection_layers[0:num_blocks]
      skip_connection_layers.reverse()
      encoder_filters.reverse()
      x = decoder_input
      if decoder_type.lower() == 'transpose':
          for decoder_block_id in range(num_blocks):
              skip_conn = skip_connection_layers[decoder_block_id]
              num_filters = encoder_filters[decoder_block_id]
              x = Conv2DTranspose(num_filters, 3, strides=(2, 2), 
                                  padding="same")(x)
              if decoder_use_skip_connection:
                  x = concatenate([x, skip_conn], axis=-1)
              for block_layer_id in range(num_decoder_block_conv_layers):
                  x = convolution_block(x,
                                        num_filters=num_filters,
                                        kernel_size=(3, 3),
                                        dilation_rate=1,
                                        padding="same",
                                        use_bias=False,
                                        use_batchnorm=decoder_use_batchnorm,
                                        activation=decoder_activation)                         
  
      elif decoder_type.lower() == 'upsampling':
          for decoder_block_id in range(num_blocks):
              skip_conn = skip_connection_layers[decoder_block_id]
              num_filters = encoder_filters[decoder_block_id]
              num_filters = encoder_filters[decoder_block_id]
              x = UpSampling2D(size=(2, 2))(x)
              x = Conv2D(num_filters, (3, 3), padding='same')(x)
              x = Activation(decoder_activation)(x)
              if decoder_use_skip_connection:
                  x = concatenate([x, skip_conn], axis=-1)
              for block_layer_id in range(num_decoder_block_conv_layers):
                  x = convolution_block(x,
                                        num_filters=num_filters,
                                        kernel_size=(3, 3),
                                        dilation_rate=1,
                                        padding="same",
                                        use_bias=False,
                                        use_batchnorm=decoder_use_batchnorm,
                                        activation=decoder_activation)
  
      x = Conv2D(encoder_filters[-1], 3, activation='relu', padding='same',
                 kernel_initializer='he_normal')(x)
  
      x = Dropout(decoder_dropout_rate)(x)
  
      x = Conv2D(filters=num_classes, kernel_size=(1, 1), 
                 activation=output_activation, padding='same')(x)
  
      return x
code_tokens: def unet_decoder ( num_classes , decoder_input , skip_connection_layers , encoder_filters = [ 32 , 64 , 128 , 256 , 512 ] , decoder_type = 'upsampling' , num_blocks = 5 , num_decoder_block_conv_layers = 1 , decoder_activation = None , decoder_use_skip_connection = True , decoder_use_batchnorm = True , decoder_dropout_rate = 0 , output_activation = None ) : if num_classes < 2 : raise ValueError ( "The `num_classes` argument cannot be less than 2." ) elif not ( isinstance ( num_classes , int ) ) : raise ValueError ( "The `num_classes` argumentcan only be an integer." ) if not isinstance ( num_blocks , int ) : raise ValueError ( 'The `num_blocks` argument should be integer' ) elif num_blocks <= 0 : raise ValueError ( 'The `num_blocks` argument cannot be less ' 'than or equal to zero' ) if not isinstance ( num_decoder_block_conv_layers , int ) : raise ValueError ( 'The `num_decoder_block_conv_layers` argument should ' 'be integer' ) elif num_decoder_block_conv_layers <= 0 : raise ValueError ( 'The `num_decoder_block_conv_layers` argument cannot ' 'be less than or equal to zero' ) if decoder_activation == None : decoder_activation = 'relu' if not isinstance ( decoder_use_batchnorm , bool ) : raise ValueError ( "The `decoder_use_batchnorm` argument should " "either be True or False." ) if not ( isinstance ( decoder_dropout_rate , int ) or isinstance ( decoder_dropout_rate , float ) ) : raise ValueError ( 'The `decoder_use_dropout` argument should be' ' an integer or float between 0 and 1' ) elif decoder_dropout_rate < 0 or decoder_dropout_rate > 1 : raise ValueError ( "The `decoder_use_dropout` argument cannot be " "less than 0 or greater than 1." ) if output_activation == None : if num_classes == 2 : output_activation = 'sigmoid' else : output_activation = 'softmax' encoder_filters = encoder_filters [ 0 : num_blocks ] skip_connection_layers = skip_connection_layers [ 0 : num_blocks ] skip_connection_layers . reverse ( ) encoder_filters . reverse ( ) x = decoder_input if decoder_type . lower ( ) == 'transpose' : for decoder_block_id in range ( num_blocks ) : skip_conn = skip_connection_layers [ decoder_block_id ] num_filters = encoder_filters [ decoder_block_id ] x = Conv2DTranspose ( num_filters , 3 , strides = ( 2 , 2 ) , padding = "same" ) ( x ) if decoder_use_skip_connection : x = concatenate ( [ x , skip_conn ] , axis = - 1 ) for block_layer_id in range ( num_decoder_block_conv_layers ) : x = convolution_block ( x , num_filters = num_filters , kernel_size = ( 3 , 3 ) , dilation_rate = 1 , padding = "same" , use_bias = False , use_batchnorm = decoder_use_batchnorm , activation = decoder_activation ) elif decoder_type . lower ( ) == 'upsampling' : for decoder_block_id in range ( num_blocks ) : skip_conn = skip_connection_layers [ decoder_block_id ] num_filters = encoder_filters [ decoder_block_id ] num_filters = encoder_filters [ decoder_block_id ] x = UpSampling2D ( size = ( 2 , 2 ) ) ( x ) x = Conv2D ( num_filters , ( 3 , 3 ) , padding = 'same' ) ( x ) x = Activation ( decoder_activation ) ( x ) if decoder_use_skip_connection : x = concatenate ( [ x , skip_conn ] , axis = - 1 ) for block_layer_id in range ( num_decoder_block_conv_layers ) : x = convolution_block ( x , num_filters = num_filters , kernel_size = ( 3 , 3 ) , dilation_rate = 1 , padding = "same" , use_bias = False , use_batchnorm = decoder_use_batchnorm , activation = decoder_activation ) x = Conv2D ( encoder_filters [ - 1 ] , 3 , activation = 'relu' , padding = 'same' , kernel_initializer = 'he_normal' ) ( x ) x = Dropout ( decoder_dropout_rate ) ( x ) x = Conv2D ( filters = num_classes , kernel_size = ( 1 , 1 ) , activation = output_activation , padding = 'same' ) ( x ) return x
short_docstring: Instantiates decoder architecture for the U-Net segmmantation model.
short_docstring_tokens: Instantiates decoder architecture for the U - Net segmmantation model .
comment: """
      Instantiates decoder architecture for the U-Net segmmantation model.
      Args:
          num_classes: number of the segmentation classes.
          decoder_input: decoder input or encoder model output.
          skip_connection_layers: encoder block outputs before pooling.
                                  They will serve as skip connection inputs
                                  for the decoder blocks.
          encoder_filters: (optional) a list containing filter sizes for each 
                            encoder block. Default to [32, 64, 128, 256].
          decoder_type: (optional) one of 'transpose' (to use Conv2DTanspose
                        operation for upsampling operation) or 'upsampling'
                        (to use UpSampling2D operation for upsampling operation).
                        Default to upsampling.
          num_blocks: (optional) number of encoder/decoder blocks to use. 
                      Default to 5.
          decoder_filters: (optional) a list containing filter sizes for each 
                            decoder block. Default to [512, 256, 128, 64, 32].
          num_decoder_block_conv_layers: (optional) number of convolution layers 
                                          for each decoder block (i.e. number of 
                                          Conv2D layers after upsampling layers). 
                                          Default to 1.
          decoder_activation: (optional) decoder activation name or function.
          decoder_use_skip_connection: (optional) one of True (to use skip
                                       connections) or False (not to use skip
                                       connections). Default to True.
          decoder_use_batchnorm: (optional) boolean to specify whether to
                                  use BatchNormalization or not. Default to True.
          decoder_dropout_rate: (optional) dropout rate. Float between 0 and 1.
          output_activation: (optional) activation for output layer.
                              Default is either 'sigmoid' or 'softmax' based on
                              the value of the 'num_classes' argument.
      Returns:
          x: decoder output
      """$SEP$#--------------------------------------------------------------------------#$SEP$# Validate and preprocess arguments$SEP$#--------------------------------------------------------------------------#$SEP$# 1. number of classes specified$SEP$# 2. num_blocks$SEP$# 3. num_decoder_block_conv_layers$SEP$# 4. decoder_activation=None$SEP$# 5. decoder_use_batchnorm=False,$SEP$# 6. decoder_dropout_rate=0$SEP$# 7. output activation$SEP$#--------------------------------------------------------------------------#$SEP$# Build the decoder blocks from the arguments specified$SEP$#--------------------------------------------------------------------------#$SEP$## Decoder Blocks