<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_session(region, profile=None):
 """Creates a boto3 session with a cache Args: region (str):
 The region for the session profile (str):
 The profile for the session Returns: :class:`boto3.session.Session`: A boto3 session with credential caching """

    if profile is None:
        logger.debug("No AWS profile explicitly provided. "
                     "Falling back to default.")
        profile = default_profile

    logger.debug("Building session using profile \"%s\" in region \"%s\""
                 % (profile, region))

    session = boto3.Session(region_name=region, profile_name=profile)
    c = session._session.get_component('credential_provider')
    provider = c.get_provider('assume-role')
    provider.cache = credential_cache
    provider._prompter = ui.getpass
    return session