<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def image_needs_building(image):
 """Return whether an image needs building Checks if the image exists (ignores commit range), either locally or on the registry. Args: image (str):
 the `repository:tag` image to be build. Returns: True: if image needs to be built False: if not (image already exists) """

    d = docker_client()

    # first, check for locally built image
    try:
        d.images.get(image)
    except docker.errors.ImageNotFound:
        # image not found, check registry
        pass
    else:
        # it exists locally, no need to check remote
        return False

    # image may need building if it's not on the registry
    return image_needs_pushing(image)