<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def resolve_image_name(self, image_name):
 """Look up an AMI for the connected region based on an image name. :param image_name: The name of the image to resolve. :type image_name: str :return: The AMI for the given image. :rtype: str """

        # look at each scope in order of size
        scopes = ['self', 'amazon', 'aws-marketplace']
        if image_name in self.remote_images:
            return self.remote_images[image_name]
        for scope in scopes:
            logger.info('Retrieving available AMIs owned by %s...', scope)
            remote_images = self.ec2.get_all_images(owners=[scope], filters={'name': image_name})
            self.remote_images.update({ri.name: ri.id for ri in remote_images})
            if image_name in self.remote_images:
                return self.remote_images[image_name]
        raise EC2ManagerException('Failed to resolve AMI name "%s" to an AMI' % image_name)