def download_result_from_gs(bucket_name, blob_name, to_filename=None):
    """Download a file from Google Cloud Storage.

    This function assumes that the local environment is configured to access the
    target bucket. This would typically be done through the gcloud command line
    utility. More information can be found here:
    https://cloud.google.com/sdk/gcloud/

    The credentials can also be overriden with Service Account credentials
    directly through the `GOOGLE_APPLICATION_CREDENTIALS` environment variable:
    https://cloud.google.com/docs/authentication/getting-started
    """
    try:
        from google.cloud import storage
    except ImportError:
        raise Exception(
            'The google-cloud-storage package is required to download results from Google Cloud Storage buckets. For details, see: https://pypi.org/project/google-cloud-storage/'
            )
    storage_client = storage.Client()
    bucket = storage_client.get_bucket(bucket_name)
    if blob_name[0] == '/':
        blob_name = blob_name[1:]
    blob = bucket.blob(blob_name)
    if to_filename:
        blob.download_to_filename(to_filename)
        return to_filename
    else:
        return blob.download_as_string()
