docstr: Returns the learned model.
  
  :return: the learned model.
docstr_tok: ["Returns","the","learned","model",".",":","return",":","the","learned","model","."]
code: def get_model(self, set_weights: bool = True) -> "Model":
      """
      Returns the learned model.
  
      :return: the learned model.
      """
      if self.model_creator is not None:
          model = self.model_creator(self.config)
      else:
          if self.load_params is not None:
              model = load_model(**self.load_params)  # type:ignore
          else:
              invalidInputError(
                  False,
                  "Please load a saved model when model_creator is None.",
              )
  
      if set_weights:
          if self.optimizer_weights is not None:
              import tensorflow as tf
  
              grad_vars = model.trainable_weights
              zero_grads = [tf.zeros_like(w) for w in grad_vars]
              model.optimizer.apply_gradients(
                  zip(zero_grads, grad_vars)
              )
              model.optimizer.set_weights(self.optimizer_weights)
          if self.model_weights is not None:
              model.set_weights(self.model_weights)
      return model
  
imports: import os
  import types
  import logging
  import tempfile
  import shutil
  from bigdl.dllib.utils.common import get_node_and_core_number
  from bigdl.dllib.utils.file_utils import is_local_path
  from bigdl.dllib.utils.utils import get_node_ip
  from bigdl.orca.data.file import is_file, exists, get_remote_file_to_local, get_remote_files_with_prefix_to_local, put_local_file_to_remote, put_local_files_with_prefix_to_remote
  from bigdl.orca.learn.tf2.spark_runner import SparkRunner
  from bigdl.orca.learn.utils import find_free_port, find_ip_and_free_port
  from bigdl.orca.learn.utils import maybe_dataframe_to_xshards, dataframe_to_xshards, convert_predict_xshards_to_dataframe, make_data_creator, load_model, save_model, process_xshards_of_pandas_dataframe, add_predict_to_pd_xshards, update_predict_xshards
  from bigdl.orca.learn.log_monitor import start_log_server, stop_log_server
  from bigdl.orca import OrcaContext
  from bigdl.orca.data.shard import SparkXShards
  from bigdl.dllib.utils.log4Error import invalidInputError
  from pyspark.sql.dataframe import DataFrame
  from typing import TYPE_CHECKING, Any, Dict, List, Callable, Union, Optional
label_desc: Use image node_id 10 for calling the SparkTFEstimator obj's underlying member method code with example usage: obj.get_model(set_weights) and returns: model