def METHOD_NAME(self,
                               sem_seg,
                               center_heatmap,
                               offsets,
                               foreground_mask=None):
    if foreground_mask is not None:
        thing_seg = foreground_mask
    else:
        # Inference from semantic segmentation
        thing_seg = paddle.zeros_like(sem_seg).astype('bool')
        for thing_class in list(self.thing_ids):
            thing_seg |= sem_seg == thing_class
        thing_seg = paddle.cast(thing_seg, paddle.int64)
    instance, center = self._get_instance_segmentation(
        sem_seg, center_heatmap, offsets, thing_seg)
    panoptic = self._merge_semantic_and_instance(sem_seg, instance,
                                                 thing_seg)
    return panoptic