def METHOD_NAME(self, pred_results: torch.Tensor,
                       data_sample: TextDetDataSample,
                       **kwargs) -> TextDetDataSample:
    """
    Args:
        pred_result (torch.Tensor): Prediction results of an image which
            is a tensor of shape :math:`(N, H, W)`.
        data_sample (TextDetDataSample): Datasample of an image.
    Returns:
        TextDetDataSample: A new DataSample with predictions filled in.
        Polygons and results are saved in
        ``TextDetDataSample.pred_instances.polygons``. The confidence
        scores are saved in ``TextDetDataSample.pred_instances.scores``.
    """
    assert pred_results.dim() == 3
    pred_results = torch.sigmoid(pred_results)  # text confidence
    masks = pred_results > self.min_kernel_confidence
    text_mask = masks[0, :, :]
    kernel_masks = masks[0:, :, :] * text_mask
    kernel_masks = kernel_masks.data.cpu().numpy().astype(np.uint8)
    score = pred_results[0, :, :]
    score = score.data.cpu().numpy().astype(np.float32)
    region_num, labels = cv2.connectedComponents(
        kernel_masks[-1], connectivity=4)
    labels = contour_expand(kernel_masks, labels, self.min_kernel_area,
                            region_num)
    labels = np.array(labels)
    label_num = np.max(labels)
    polygons = []
    scores = []
    for i in range(1, label_num + 1):
        points = np.array(np.where(labels == i)).transpose((1, 0))[:, ::-1]
        area = points.shape[0]
        score_instance = np.mean(score[labels == i])
        if not (area >= self.min_text_area
                or score_instance > self.score_threshold):
            continue
        polygon = self._points2boundary(points)
        if polygon:
            polygons.append(polygon)
            scores.append(score_instance)
    pred_instances = InstanceData()
    pred_instances.polygons = polygons
    pred_instances.scores = torch.FloatTensor(scores)
    data_sample.pred_instances = pred_instances
    scale_factor = data_sample.scale_factor
    scale_factor = tuple(factor * self.downsample_ratio
                         for factor in scale_factor)
    data_sample.set_metainfo(dict(scale_factor=scale_factor))
    return data_sample