<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def pdf_extraction(pdf, cloud=None, batch=False, api_key=None, version=None, **kwargs):
 """ Given a pdf, returns the text and metadata associated with the given pdf. PDFs may be provided as base64 encoded data or as a filepath. Base64 image data and formatted table is optionally returned by setting `images=True` or `tables=True`. Example usage: .. code-block:: python ['text', 'metadata'] :param pdf: The pdf to be analyzed. :type pdf: str or list of strs :rtype: dict or list of dicts """

    pdf = pdf_preprocess(pdf, batch=batch)
    url_params = {"batch": batch, "api_key": api_key, "version": version}
    results = api_handler(pdf, cloud=cloud, api="pdfextraction", url_params=url_params, **kwargs)

    if batch:
        for result in results:
            result["images"] = postprocess_images(result.get("images", []))
    else:
        results['images'] = postprocess_images(results.get("images", []))
    return results