def METHOD_NAME(
    image_name: str,
    image_version: str,
    name: str,
    environment: dict[str, str] | None = None,
    ports: dict[str, str] | None = None,
    **run_kwargs: Any,
) -> Generator[Container, None, None]:
    logger = logging.getLogger(__name__)
    image_str = f"{image_name}:{image_version}"
    docker_client = docker.from_env()
    found = False
    for i in docker_client.images.list():
        try:
            if i.tags[0] == image_str:
                found = True
        except IndexError:
            pass
    if not found:
        logger.info(f"Downloading docker image {image_str}")
        docker_client.images.pull(image_str)
    logger.info(f"Starting docker image {image_str}")
    container = docker_client.containers.run(
        image=image_str,
        name=name,
        auto_remove=True,
        detach=True,
        environment=environment,
        ports=ports,
        **run_kwargs,
    )
    try:
        yield container
    finally:
        container.kill()