Optimizing docker image size
I am building a docker image for my python app using the base image python:3.5-slim-buster. 

I am running the below command inside the Dockerfile:

RUN pip install --no-cache-dir -r requirements.txt which has torch library in the requirements file.

After building the image it is having a size of 2.29 GB. But if I build the image without torch inside the requirements file, it has only ~900 MB.

when I manually run the image and check inside the container:

The torch (/usr/local/lib/python3.5/site-packages/torch) directory is 1.3GB.

So even if I do a multistage build and try to copy the contents from 
/usr/local/lib/python3.5/site-packages to a new image, I suppose it is not going to help me.

Is there any other standard optimization practice which can help me to reduce the image size?

Assuming you want a trained model of some kind from pytorch (usually neural network) you should indeed use multistage Docker build as follows (IMO at least):

1. Training model and exporting

Write your script as per usual, including all dependencies you need. Train your model and save it as artifact using torchscript's torch.jit.script.

2. Second stage

Using C++ write inference code loading your net and compile the source (use libtorch).

3. Final image

Copy binary from previous step and put it is as Docker's entrypoint so you can run it as disposable neural net within container.
