﻿Convert the following bloated Dockerfile into an optimized multi-stage build that minimizes the final image size.

`dockerfile
FROM python:3.11
WORKDIR /app
RUN apt-get update && apt-get install -y gcc libpq-dev curl wget vim net-tools
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
RUN python -m pytest tests/
RUN python setup.py build
EXPOSE 8000
CMD ["python", "-m", "uvicorn", "app.main:app", "--host", "0.0.0.0"]
`

The optimized version should: use multi-stage builds, separate build and runtime dependencies, use a slim or distroless base for the final stage, not include test files or build tools in the final image, and leverage layer caching effectively. Explain each optimization and estimate the size reduction.
