pub fn parse_device(device: Option<&Bound<'_, PyAny>>) -> PyResult<DeviceType>
Helper function to parse device from Python arguments