code: def reverse_transform_for_single_map(
      pred, trans_info, mode="nearest"
  ):
      """Recover `pred` to original shape"""
      intTypeList = [
          paddle.int8,
          paddle.int16,
          paddle.int32,
          paddle.int64,
      ]
      dtype = pred.dtype
      for item in trans_info[::-1]:
          if isinstance(item[0], list):
              trans_mode = item[0][0]
          else:
              trans_mode = item[0]
          if trans_mode == "resize":
              h, w = item[1][0], item[1][1]
              ndims = pred.dim()
              if ndims < 4:
                  for _ in range(4 - ndims):
                      pred = pred.unsqueeze(0)
              elif ndims > 4:
                  raise ValueError
              if paddle.get_device() == "cpu" and dtype in intTypeList:
                  pred = paddle.cast(pred, "float32")
                  # align_corners=False matches the result of OpenCV
                  pred = F.interpolate(
                      pred, [h, w], mode=mode, align_corners=False
                  )
                  pred = paddle.cast(pred, dtype)
              else:
                  pred = F.interpolate(
                      pred, [h, w], mode=mode, align_corners=False
                  )
              if ndims < 4:
                  for _ in range(4 - ndims):
                      pred = pred.squeeze(0)
          elif trans_mode == "padding":
              h, w = item[1][0], item[1][1]
              pred = pred[..., 0:h, 0:w]
          else:
              raise ValueError(
                  "Unexpected info '{}' in im_info".format(item[0])
              )
      return pred
  
imports: import paddle
  import paddle.nn.functional
label_desc: Use image node_id 1 for calling a global function with example usage: reverse_transform_for_single_map(pred, trans_info, mode) and returns: pred