<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _apply_credentials(auto_refresh=True, credentials=None, headers=None):
 """Update Authorization header. Update request headers with latest `access_token`. Perform token `refresh` if token is ``None``. Args: auto_refresh (bool):
 Perform token refresh if access_token is ``None`` or expired. Defaults to ``True``. credentials (class):
 Read-only credentials. headers (class):
 Requests `CaseInsensitiveDict`. """

        token = credentials.get_credentials().access_token
        if auto_refresh is True:
            if token is None:
                token = credentials.refresh(
                    access_token=None, timeout=10)
            elif credentials.jwt_is_expired():
                token = credentials.refresh(timeout=10)
        headers.update(
            {'Authorization': "Bearer {}".format(token)}
        )