<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _read_with_mask(raster, masked):
 """ returns if we should read from rasterio using the masked """

        if masked is None:
            mask_flags = raster.mask_flag_enums
            per_dataset_mask = all([rasterio.enums.MaskFlags.per_dataset in flags for flags in mask_flags])
            masked = per_dataset_mask
        return masked