<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def predict_heatmap(pdf_path, page_num, model, img_dim=448, img_dir="tmp/img"):
 """ Return an image corresponding to the page of the pdf documents saved at pdf_path. If the image is not found in img_dir this function creates it and saves it in img_dir. :param pdf_path: path to the pdf document. :param page_num: page number to create image from in the pdf file. :return: """

    if not os.path.isdir(img_dir):
        print("\nCreating image folder at {}".format(img_dir))
        os.makedirs(img_dir)
    pdf_name = os.path.splitext(os.path.basename(pdf_path))[0]
    # TODO: add hashing function to make sure name is unique
    # TODO: add parallelization
    img_path = os.path.join(img_dir, pdf_name + "-{}.png".format(page_num))
    if not os.path.isfile(img_path):
        # create image for a page in the pdf document and save it in img_dir
        save_image(pdf_path, img_path, page_num)
    image = load_img(img_path, grayscale=True, target_size=(img_dim, img_dim))
    image = img_to_array(image, data_format=K.image_data_format())
    image = (
        image.reshape((img_dim, img_dim, 1))
        .repeat(3, axis=2)
        .reshape((1, img_dim, img_dim, 3))
    )
    return (
        image.astype(np.uint8).reshape((img_dim, img_dim, 3)),
        model.predict(image).reshape((img_dim, img_dim)),
    )