code: def test_api_training_determinism(tmpdir):
      input_features = [
          sequence_feature(encoder={"reduce_output": "sum"})
      ]
      output_features = [
          category_feature(
              decoder={"vocab_size": 5}, reduce_input="sum"
          )
      ]
  
      data_csv = generate_data(
          input_features,
          output_features,
          os.path.join(tmpdir, "dataset.csv"),
      )
  
      config = {
          "input_features": input_features,
          "output_features": output_features,
          "combiner": {"type": "concat", "output_size": 14},
          "trainer": {
              BATCH_SIZE: 128
          },  # batch size must be fixed for determinism
      }
  
      # Train the model 3 times:
      #
      # 1. seed x
      # 2. seed y
      # 3. seed x
      #
      # Check that models (1) and (3) produce the same weights,
      # but (1) and (2) do not
      rand_x = 42
      rand_y = 24
  
      model_1 = LudwigModel(config)
      model_1.train(
          dataset=data_csv, output_directory=tmpdir, random_seed=rand_x
      )
  
      model_2 = LudwigModel(config)
      model_2.train(
          dataset=data_csv, output_directory=tmpdir, random_seed=rand_y
      )
  
      model_3 = LudwigModel(config)
      model_3.train(
          dataset=data_csv, output_directory=tmpdir, random_seed=rand_x
      )
  
      model_weights_1 = get_weights(model_1.model)
      model_weights_2 = get_weights(model_2.model)
      model_weights_3 = get_weights(model_3.model)
  
      divergence = False
      for weight_1, weight_2 in zip(model_weights_1, model_weights_2):
          if not torch.allclose(weight_1, weight_2):
              divergence = True
              break
      assert (
          divergence
      ), "model_1 and model_2 have identical weights with different seeds!"
  
      for weight_1, weight_3 in zip(model_weights_1, model_weights_3):
          assert torch.allclose(weight_1, weight_3)
  
imports: import json
  import os
  import shutil
  from unittest import mock
  import pandas
  import pytest
  import torch
  import yaml
  from ludwig.api import LudwigModel
  from ludwig.callbacks import Callback
  from ludwig.constants import BATCH_SIZE, ENCODER, TRAINER, TYPE
  from ludwig.globals import MODEL_HYPERPARAMETERS_FILE_NAME
  from ludwig.models.inference import InferenceModule
  from ludwig.utils.data_utils import read_csv
  from tests.integration_tests.utils import category_feature, ENCODERS, generate_data, get_weights, image_feature, run_api_experiment, sequence_feature, text_feature
label_desc: Use image node_id 6 for calling a global function with example usage: test_api_training_determinism(tmpdir) without return types