<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def process_tarball(tarball, output_directory=None, context=False):
 """Process one tarball end-to-end. If output directory is given, the tarball will be extracted there. Otherwise, it will extract it in a folder next to the tarball file. The function returns a list of dictionaries: .. code-block:: python [{ 'url': '/path/to/tarball_files/d15-120f3d.png', 'name': 'd15-120f3d', 'label': 'fig:mass' :param: tarball (string):
 the absolute location of the tarball we wish to process :param: output_directory (string):
 path of file processing and extraction (optional) :param: context: if True, also try to extract context where images are referenced in the text. (optional) :return: images(list):
 list of dictionaries for each image with captions. """

    if not output_directory:
        # No directory given, so we use the same path as the tarball
        output_directory = os.path.abspath("{0}_files".format(tarball))

    extracted_files_list = untar(tarball, output_directory)
    image_list, tex_files = detect_images_and_tex(extracted_files_list)

    if tex_files == [] or tex_files is None:
        raise NoTexFilesFound("No TeX files found in {0}".format(tarball))

    converted_image_mapping = convert_images(image_list)
    return map_images_in_tex(
        tex_files,
        converted_image_mapping,
        output_directory,
        context
    )