How to override productcollection.php from vendor?

I have to override the file ProductCollection.php from vendor/magento/module-catalog/Ui/DataProvider/Product.

I have read many posts but still not getting to override the file.

Can anyone please explain it to me step by step?

Your help is greatly appreciated.