code: def _should_log_model(spark_model):
      from pyspark.ml.base import Model
  
      # TODO: Handle PipelineModel/CrossValidatorModel/TrainValidationSplitModel
      class_name = _get_fully_qualified_class_name(spark_model)
      should_log = class_name in _log_model_allowlist
      if not should_log:
          for name in _log_model_allowlist:
              # only support one trailing *
              if name.endswith("*") and class_name.startswith(
                  name[:-1]
              ):
                  should_log = True
                  break
      if should_log:
          if class_name == "pyspark.ml.classification.OneVsRestModel":
              return _should_log_model(spark_model.models[0])
          elif class_name == "pyspark.ml.pipeline.PipelineModel":
              return all(
                  _should_log_model(stage)
                  for stage in spark_model.stages
                  if isinstance(stage, Model)
              )
          elif _is_parameter_search_model(spark_model):
              return _should_log_model(spark_model.bestModel)
          else:
              return all(
                  _should_log_model(param_value)
                  for _, param_value in _get_param_map(
                      spark_model
                  ).items()
                  # Transformers are logged by default as the same behavior as PipelineModel
                  if isinstance(param_value, Model)
              )
      else:
          return False
  
imports: import json
  import logging
  import os
  import sys
  import traceback
  import weakref
  from collections import OrderedDict, defaultdict, namedtuple
  from itertools import zip_longest
  from urllib.parse import urlparse
  import numpy
  import mlflow
  from mlflow.data.code_dataset_source import CodeDatasetSource
  from mlflow.data.spark_dataset import SparkDataset
  from mlflow.entities import Metric, Param
  from mlflow.entities.dataset_input import DatasetInput
  from mlflow.entities.input_tag import InputTag
  from mlflow.exceptions import MlflowException
  from mlflow.tracking.client import MlflowClient
  from mlflow.utils import _chunk_dict, _get_fully_qualified_class_name, _inspect_original_var_name, _truncate_dict
  from mlflow.utils.autologging_utils import INPUT_EXAMPLE_SAMPLE_ROWS, _get_new_training_session_class, autologging_integration, get_method_call_arg_value, resolve_input_example_and_signature, safe_patch
  from mlflow.utils.file_utils import TempDir
  from mlflow.utils.mlflow_tags import MLFLOW_AUTOLOGGING, MLFLOW_DATASET_CONTEXT, MLFLOW_PARENT_RUN_ID
  from mlflow.utils.rest_utils import MlflowHostCreds, augmented_raise_for_status, http_request
  from mlflow.utils.time import get_current_time_millis
  from mlflow.utils.validation import MAX_ENTITY_KEY_LENGTH, MAX_PARAM_VAL_LENGTH, MAX_PARAMS_TAGS_PER_BATCH
label_desc: Use image node_id 4 for calling a global function with example usage: _should_log_model(spark_model) and returns: False, _should_log_model, all, _should_log_model, all