def read_env_vars_and_defaults(var: str) -> Optional[str]:
    """Attempts to read an environment variable.
    If none is found, it will attempt to retrieve it from
    configs.default_env_vars(). If still unsuccessful, None is returned.
    If it's an empty string, None is returned.
    """

    def none_if_empty(value: Optional[str]) -> Optional[str]:
        """Returns None if value is an empty string"""
        if value is not None and len(value) == 0:
            return None
        else:
            return value

    try:
        return none_if_empty(os.environ[var])
    except KeyError:
        try:
            default_val = configs.default_env_vars()[var]
            if isinstance(default_val, str):
                return none_if_empty(default_val)
            else:
                return default_val
        except KeyError:
            return None
Attempts to read an environment variable.
    If none is found, it will attempt to retrieve it from
    configs.default_env_vars(). If still unsuccessful, None is returned.
    If it's an empty string, None is returned.
    
src/marqo/tensor_search/utils.py