def _fit_imaging_from(fit: af.Fit, galaxies: List[ag.Galaxy], settings_imaging: aa.SettingsImaging=None, settings_pixelization: aa.SettingsPixelization=None, settings_inversion: aa.SettingsInversion=None, use_preloaded_grid: bool=True, use_hyper_scaling: bool=True) -> FitImaging:
    '\n    Returns a `FitImaging` object from a PyAutoFit database `Fit` object and an instance of galaxies from a non-linear\n    search model-fit.\n\n    This function adds the `hyper_model_image` and `hyper_galaxy_image_path_dict` to the galaxies before performing the\n    fit, if they were used.\n\n    Parameters\n    ----------\n    fit\n        A PyAutoFit database Fit object containing the generators of the results of PyAutoGalaxy model-fits.\n    galaxies\n        A list of galaxies corresponding to a sample of a non-linear search and model-fit.\n\n    Returns\n    -------\n    FitImaging\n        The fit to the imaging dataset computed via an instance of galaxies.\n    '
    imaging = _imaging_from(fit=fit, settings_imaging=settings_imaging)
    tracer = _tracer_from(fit=fit, galaxies=galaxies)
    settings_pixelization = (settings_pixelization or fit.value(name='settings_pixelization'))
    settings_inversion = (settings_inversion or fit.value(name='settings_inversion'))
    preloads = Preloads(use_w_tilde=False)
    if use_preloaded_grid:
        sparse_grids_of_planes = fit.value(name='preload_sparse_grids_of_planes')
        if (sparse_grids_of_planes is not None):
            preloads = Preloads(sparse_image_plane_grid_pg_list=sparse_grids_of_planes, use_w_tilde=False)
            if (len(preloads.sparse_image_plane_grid_pg_list) == 2):
                if (type(preloads.sparse_image_plane_grid_pg_list[1]) != list):
                    preloads.sparse_image_plane_grid_pg_list[1] = [preloads.sparse_image_plane_grid_pg_list[1]]
    return FitImaging(dataset=imaging, tracer=tracer, settings_pixelization=settings_pixelization, settings_inversion=settings_inversion, preloads=preloads, use_hyper_scaling=use_hyper_scaling)
Returns a `FitImaging` object from a PyAutoFit database `Fit` object and an instance of galaxies from a non-linear
search model-fit.

This function adds the `hyper_model_image` and `hyper_galaxy_image_path_dict` to the galaxies before performing the
fit, if they were used.

Parameters
----------
fit
    A PyAutoFit database Fit object containing the generators of the results of PyAutoGalaxy model-fits.
galaxies
    A list of galaxies corresponding to a sample of a non-linear search and model-fit.

Returns
-------
FitImaging
    The fit to the imaging dataset computed via an instance of galaxies.
def _fit_imaging_from(fit: af.Fit, galaxies: List[ag.Galaxy], settings_imaging: aa.SettingsImaging=None, settings_pixelization: aa.SettingsPixelization=None, settings_inversion: aa.SettingsInversion=None, use_preloaded_grid: bool=True, use_hyper_scaling: bool=True) -> FitImaging:
    '\n    Returns a `FitImaging` object from a PyAutoFit database `Fit` object and an instance of galaxies from a non-linear\n    search model-fit.\n\n    This function adds the `hyper_model_image` and `hyper_galaxy_image_path_dict` to the galaxies before performing the\n    fit, if they were used.\n\n    Parameters\n    ----------\n    fit\n        A PyAutoFit database Fit object containing the generators of the results of PyAutoGalaxy model-fits.\n    galaxies\n        A list of galaxies corresponding to a sample of a non-linear search and model-fit.\n\n    Returns\n    -------\n    FitImaging\n        The fit to the imaging dataset computed via an instance of galaxies.\n    '
    imaging = _imaging_from(fit=fit, settings_imaging=settings_imaging)
    tracer = _tracer_from(fit=fit, galaxies=galaxies)
    settings_pixelization = (settings_pixelization or fit.value(name='settings_pixelization'))
    settings_inversion = (settings_inversion or fit.value(name='settings_inversion'))
    preloads = Preloads(use_w_tilde=False)
    if use_preloaded_grid:
        sparse_grids_of_planes = fit.value(name='preload_sparse_grids_of_planes')
        if (sparse_grids_of_planes is not None):
            preloads = Preloads(sparse_image_plane_grid_pg_list=sparse_grids_of_planes, use_w_tilde=False)
            if (len(preloads.sparse_image_plane_grid_pg_list) == 2):
                if (type(preloads.sparse_image_plane_grid_pg_list[1]) != list):
                    preloads.sparse_image_plane_grid_pg_list[1] = [preloads.sparse_image_plane_grid_pg_list[1]]
    return FitImaging(dataset=imaging, tracer=tracer, settings_pixelization=settings_pixelization, settings_inversion=settings_inversion, preloads=preloads, use_hyper_scaling=use_hyper_scaling)