[SPARK-37407][FOLLOW-UP][PYTHON][ML] Add not None assertions for active context and its _jvm
[SPARK-37407][FOLLOW-UP][PYTHON][ML] Add not None assertions for active context and its _jvm

### What changes were proposed in this pull request?

This PR add  `is not None` assertions for `Optional`  `_active_spark_context` and `_jvm`

### Why are the changes needed?

To address failures in CI:

```
python/pyspark/ml/functions.py:69: error: Item "None" of "Optional[SparkContext]" has no attribute "_jvm"  [union-attr]
python/pyspark/ml/functions.py:69: error: Item "None" of "Optional[Any]" has no attribute "org"  [union-attr]
python/pyspark/ml/functions.py:104: error: Item "None" of "Optional[SparkContext]" has no attribute "_jvm"  [union-attr]
python/pyspark/ml/functions.py:104: error: Item "None" of "Optional[Any]" has no attribute "org"  [union-attr]
```

caused by divergence between #34678 and changes introduced by #34892

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

`dev/lint-python`

Closes #35022 from zero323/SPARK-37407-FOLLOW-UP.

Authored-by: zero323 <0f81822ec43dc7f424811d0a422871ea124aa3dd@gmail.com>
Signed-off-by: zero323 <0f81822ec43dc7f424811d0a422871ea124aa3dd@gmail.com>

JoshRosen/spark,srowen/spark,wangyum/spark,apache/spark,gengliangwang/spark,xuanyuanking/spark,holdenk/spark,vinodkc/spark,gengliangwang/spark,holdenk/spark,witgo/spark,JoshRosen/spark,JoshRosen/spark,JoshRosen/spark,apache/spark,holdenk/spark,HyukjinKwon/spark,gengliangwang/spark,witgo/spark,WeichenXu123/spark,mahak/spark,zzcclp/spark,zzcclp/spark,xuanyuanking/spark,vinodkc/spark,rednaxelafx/apache-spark,holdenk/spark,witgo/spark,ueshin/apache-spark,wangyum/spark,srowen/spark,ueshin/apache-spark,gengliangwang/spark,ueshin/apache-spark,srowen/spark,nchammas/spark,xuanyuanking/spark,dongjoon-hyun/spark,ueshin/apache-spark,witgo/spark,witgo/spark,zzcclp/spark,WeichenXu123/spark,gengliangwang/spark,zero323/spark,holdenk/spark,cloud-fan/spark,rednaxelafx/apache-spark,mahak/spark,shaneknapp/spark,WeichenXu123/spark,rednaxelafx/apache-spark,wangyum/spark,HyukjinKwon/spark,gengliangwang/spark,hvanhovell/spark,gengliangwang/spark,nchammas/spark,xuanyuanking/spark,zero323/spark,JoshRosen/spark,wangyum/spark,vinodkc/spark,srowen/spark,dongjoon-hyun/spark,hvanhovell/spark,mahak/spark,hvanhovell/spark,hvanhovell/spark,zzcclp/spark,shaneknapp/spark,zero323/spark,WeichenXu123/spark,cloud-fan/spark,cloud-fan/spark,vinodkc/spark,zzcclp/spark,zero323/spark,holdenk/spark,rednaxelafx/apache-spark,nchammas/spark,HyukjinKwon/spark,srowen/spark,HyukjinKwon/spark,shaneknapp/spark,ueshin/apache-spark,zero323/spark,zero323/spark,mahak/spark,nchammas/spark,shaneknapp/spark,cloud-fan/spark,dongjoon-hyun/spark,zzcclp/spark,hvanhovell/spark,holdenk/spark,nchammas/spark,rednaxelafx/apache-spark,mahak/spark,apache/spark,WeichenXu123/spark,ueshin/apache-spark,witgo/spark,shaneknapp/spark,wangyum/spark,vinodkc/spark,shaneknapp/spark,xuanyuanking/spark,HyukjinKwon/spark,rednaxelafx/apache-spark,srowen/spark,WeichenXu123/spark,WeichenXu123/spark,apache/spark,dongjoon-hyun/spark,dongjoon-hyun/spark,mahak/spark,HyukjinKwon/spark,vinodkc/spark,apache/spark,cloud-fan/spark,wangyum/spark,apache/spark,ueshin/apache-spark,dongjoon-hyun/spark,hvanhovell/spark,shaneknapp/spark,zero323/spark,nchammas/spark,mahak/spark,xuanyuanking/spark,nchammas/spark,HyukjinKwon/spark,witgo/spark,vinodkc/spark,cloud-fan/spark,apache/spark,cloud-fan/spark,JoshRosen/spark,dongjoon-hyun/spark,wangyum/spark,srowen/spark,hvanhovell/spark,JoshRosen/spark,zzcclp/spark,xuanyuanking/spark,rednaxelafx/apache-spark