code: def train_func(config: dict):
      batch_size = config.get("batch_size", 64)
      epochs = config.get("epochs", 3)
  
      strategy = tf.distribute.MultiWorkerMirroredStrategy()
      with strategy.scope():
          # Model building/compiling need to be within `strategy.scope()`.
          multi_worker_model = build_model()
          multi_worker_model.compile(
              optimizer=tf.keras.optimizers.SGD(
                  learning_rate=config.get("lr", 1e-3)
              ),
              loss=tf.keras.losses.mean_squared_error,
              metrics=[tf.keras.metrics.mean_squared_error],
          )
  
      dataset = train.get_dataset_shard("train")
  
      results = []
      for _ in range(epochs):
          tf_dataset = dataset.to_tf(
              feature_columns="x",
              label_columns="y",
              batch_size=batch_size,
          )
          history = multi_worker_model.fit(
              tf_dataset, callbacks=[ReportCheckpointCallback()]
          )
          results.append(history.history)
      return results
  
file_path: ray/doc/source/train/doc_code/tf_starter.py
imports: import ray
  import tensorflow
  from ray import train
  from ray.train import ScalingConfig
  from ray.train.tensorflow import TensorflowTrainer
  from ray.train.tensorflow.keras import ReportCheckpointCallback
label_desc: Use image node_id 2 for calling a global function with example usage: train_func(config) and returns: results