code: def get_session(region, profile=None):
      
      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
docs: 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