code: def infer_classes_from_model(model: Optional[BasicModel]):
      """Get classes_ attribute from model object if exists."""
      if (
          model is not None
          and hasattr(model, "classes_")
          and len(model.classes_) > 0
      ):
          return sorted(list(model.classes_))
  
file_path: deepchecks/deepchecks/tabular/utils/task_inference.py
imports: from typing import Optional
  import numpy
  import pandas
  from pandas._libs.lib import infer_dtype
  from deepchecks.core.errors import ValidationError
  from deepchecks.tabular.utils.task_type import TaskType
  from deepchecks.utils.array_math import sequence_to_numpy
  from deepchecks.utils.logger import get_logger
  from deepchecks.utils.type_inference import is_categorical
  from deepchecks.utils.typing import BasicModel
label_desc: Use image node_id 1 for calling a global function with example usage: infer_classes_from_model(model) and returns: sorted