<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_image(self, image_name: str, image_tag: str, repo_path: Path, requirements_option: RequirementsOptions, dependencies: Optional[List[str]]):
 """ Builds an image for specific requirements and dependencies, based on the settings. :param image_name: How the image should be named :param image_tag: And what tag it should have. :param repo_path: Path to the cloned repository. :param requirements_option: How requirements are set in the repository. :param dependencies: List of dependencies (in the formalized format) :return: The Image instance. :rtype: docker.models.images.Image """

        if self.inherit_image is not None:
            return self.build_image_from_inherited_image(image_name, image_tag, repo_path, requirements_option)

        if requirements_option == RequirementsOptions.no_requirements:

            python_version = self.get_python_version()

            # no requirements and no dependencies, just return the basic image with the correct python installed
            if dependencies is None:
                base_name, base_tag = self.get_python_base(python_version, pull=not self.disable_pull)
                image = self.get_image(base_name, base_tag)

                # tag the image so ``build_image`` doesn't have to be called next time
                image.tag(image_name, image_tag)

                return image

            # extend the image with correct python by installing the dependencies
            def install_dependencies_dockerfile():
                base_name, base_tag = self.get_python_base(python_version, pull=not self.disable_pull)

                return self.INSTALL_DEPENDENCIES.format(
                    name=base_name,
                    tag=base_tag,
                    dependencies=" ".join(dependencies)
                )

            self.get_or_build_image(image_name, image_tag, install_dependencies_dockerfile)

            return self.get_image(image_name, image_tag)

        else:  # doesn't have to be here, but the return right above was confusing
            def install_requirements_dockerfile():
                """ Returns a Dockerfile for installing pip requirements,
                    based on a image with installed dependencies (or no extra dependencies)
                """
                dependencies_name, dependencies_tag = self.get_image_with_installed_dependencies(image_name,
                                                                                                 dependencies)

                return self.get_install_requirements_dockerfile(
                    name=dependencies_name,
                    tag=dependencies_tag,
                    repo_path=repo_path,
                    requirements_option=requirements_option,
                )

            self.get_or_build_image(image_name, image_tag, install_requirements_dockerfile,
                                    build_context=repo_path.parent, pull=False)

            return self.get_image(image_name, image_tag)