<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def build(self, runtime, layers):
 """ Build the image if one is not already on the system that matches the runtime and layers Parameters runtime str Name of the Lambda runtime layers list(samcli.commands.local.lib.provider.Layer) List of layers Returns ------- str The image to be used (REPOSITORY:TAG) """

        base_image = "{}:{}".format(self._DOCKER_LAMBDA_REPO_NAME, runtime)

        # Don't build the image if there are no layers.
        if not layers:
            LOG.debug("Skipping building an image since no layers were defined")
            return base_image

        downloaded_layers = self.layer_downloader.download_all(layers, self.force_image_build)

        docker_image_version = self._generate_docker_image_version(downloaded_layers, runtime)
        image_tag = "{}:{}".format(self._SAM_CLI_REPO_NAME, docker_image_version)

        image_not_found = False

        try:
            self.docker_client.images.get(image_tag)
        except docker.errors.ImageNotFound:
            LOG.info("Image was not found.")
            image_not_found = True

        if self.force_image_build or \
                image_not_found or \
                any(layer.is_defined_within_template for layer in downloaded_layers):
            LOG.info("Building image...")
            self._build_image(base_image, image_tag, downloaded_layers)

        return image_tag