code: def SpatialContextBlock(
      level,
      conv_filters=512,
      pooling_type="avg",
      use_batchnorm=True,
  ):
      if pooling_type not in ("max", "avg"):
          raise ValueError(
              "Unsupported pooling type - `{}`.".format(pooling_type)
              + "Use `avg` or `max`."
          )
  
      Pooling2D = (
          layers.MaxPool2D
          if pooling_type == "max"
          else layers.AveragePooling2D
      )
  
      pooling_name = "psp_level{}_pooling".format(level)
      conv_block_name = "psp_level{}".format(level)
      upsampling_name = "psp_level{}_upsampling".format(level)
  
      def wrapper(input_tensor):
          # extract input feature maps size (h, and w dimensions)
          input_shape = backend.int_shape(input_tensor)
          spatial_size = (
              input_shape[1:3]
              if backend.image_data_format() == "channels_last"
              else input_shape[2:]
          )
  
          # Compute the kernel and stride sizes according to how large the final feature map will be
          # When the kernel factor and strides are equal, then we can compute the final feature map factor
          # by simply dividing the current factor by the kernel or stride factor
          # The final feature map sizes are 1x1, 2x2, 3x3, and 6x6.
          pool_size = up_size = [
              spatial_size[0] // level,
              spatial_size[1] // level,
          ]
  
          x = Pooling2D(
              pool_size,
              strides=pool_size,
              padding="same",
              name=pooling_name,
          )(input_tensor)
          x = Conv1x1BnReLU(
              conv_filters, use_batchnorm, name=conv_block_name
          )(x)
          x = layers.UpSampling2D(
              up_size, interpolation="bilinear", name=upsampling_name
          )(x)
          return x
  
      return wrapper
  
file_path: segmentation_models/segmentation_models/models/pspnet.py
imports: from keras_applications import get_submodules_from_kwargs
  from ._common_blocks import Conv2dBn
  from ._utils import freeze_model, filter_keras_submodules
  from ..backbones.backbones_factory import Backbones
label_desc: Use image node_id 4 for calling a global function with example usage: SpatialContextBlock(level, conv_filters, pooling_type, use_batchnorm) and returns: wrapper, x