Write a clean, modular Python script to handle class imbalance in a dataset using both oversampling and custom loss weighting.