def inference(
        model,
        im,
        transforms,
        thing_list,
        label_divisor,
        stuff_area,
        ignore_index,
        threshold=0.1,
        nms_kernel=3,
        top_k=None,
        ori_shape=None, ):
    """
    Inference for image.

    Args:
        model (paddle.nn.Layer): model to get logits of image.
        im (Tensor): the input image.
        transforms (list): Transforms for image.
        thing_list (list): A List of thing class id.
        label_divisor (int): An Integer, used to convert panoptic id = semantic id * label_divisor + instance_id.
        stuff_area (int): An Integer, remove stuff whose area is less tan stuff_area.
        ignore_index (int): Specifies a value that is ignored.
        threshold (float, optional): A Float, threshold applied to center heatmap score. Default: 0.1.
        nms_kernel (int, optional): An Integer, NMS max pooling kernel size. Default: 3.
        top_k (int, optional): An Integer, top k centers to keep. Default: None.
        ori_shape (list. optional): Origin shape of image. Default: None.

    Returns:
        list: A list of [semantic, semantic_softmax, instance, panoptic, ctr_hmp].
            semantic: Semantic segmentation results with shape [1, 1, H, W], which value is 0, 1, 2...
            semantic_softmax: A Tensor represent probabilities for each class, which shape is [1, num_classes, H, W].
            instance: Instance segmentation results with class agnostic, which value is 0, 1, 2, ..., and 0 is stuff.
            panoptic: Panoptic segmentation results which value is ignore_index, stuff_id, thing_id * label_divisor + ins_id , ins_id >= 1.
    """
    logits = model(im)
    # semantic: [1, c, h, w], center: [1, 1, h, w], offset: [1, 2, h, w]
    semantic, ctr_hmp, offset = logits
    semantic = paddle.argmax(semantic, axis=1, keepdim=True)
    semantic = semantic.squeeze(0)  # shape: [1, h, w]
    semantic_softmax = F.softmax(logits[0], axis=1).squeeze()
    ctr_hmp = ctr_hmp.squeeze(0)  # shape: [1, h, w]
    offset = offset.squeeze(0)  # shape: [2, h, w]

    instance, center = get_instance_segmentation(
        semantic=semantic,
        ctr_hmp=ctr_hmp,
        offset=offset,
        thing_list=thing_list,
        threshold=threshold,
        nms_kernel=nms_kernel,
        top_k=top_k)
    panoptic = merge_semantic_and_instance(semantic, instance, label_divisor,
                                           thing_list, stuff_area, ignore_index)

    # Recover to origin shape
    # semantic: 0, 1, 2, 3...
    # instance: 0, 1, 2, 3, 4,  5... and the 0 is stuff.
    # panoptic: ignore_index, stuff_id, thing_id * label_divisor + ins_id , ins_id >= 1.
    results = [semantic, semantic_softmax, instance, panoptic, ctr_hmp]
    if ori_shape is not None:
        results = [i.unsqueeze(0) for i in results]
        results = [
            reverse_transform(
                i, ori_shape=ori_shape, transforms=transforms) for i in results
        ]

    return results

    Inference for image.

    Args:
        model (paddle.nn.Layer): model to get logits of image.
        im (Tensor): the input image.
        transforms (list): Transforms for image.
        thing_list (list): A List of thing class id.
        label_divisor (int): An Integer, used to convert panoptic id = semantic id * label_divisor + instance_id.
        stuff_area (int): An Integer, remove stuff whose area is less tan stuff_area.
        ignore_index (int): Specifies a value that is ignored.
        threshold (float, optional): A Float, threshold applied to center heatmap score. Default: 0.1.
        nms_kernel (int, optional): An Integer, NMS max pooling kernel size. Default: 3.
        top_k (int, optional): An Integer, top k centers to keep. Default: None.
        ori_shape (list. optional): Origin shape of image. Default: None.

    Returns:
        list: A list of [semantic, semantic_softmax, instance, panoptic, ctr_hmp].
            semantic: Semantic segmentation results with shape [1, 1, H, W], which value is 0, 1, 2...
            semantic_softmax: A Tensor represent probabilities for each class, which shape is [1, num_classes, H, W].
            instance: Instance segmentation results with class agnostic, which value is 0, 1, 2, ..., and 0 is stuff.
            panoptic: Panoptic segmentation results which value is ignore_index, stuff_id, thing_id * label_divisor + ins_id , ins_id >= 1.
    
contrib/PanopticDeepLab/core/infer.py