code: def test_model_weights_match_training(tmpdir, csv_filename):
      np.random.seed(1)
  
      input_features = [number_feature()]
      output_features = [number_feature()]
      output_feature_name = output_features[0][NAME]
  
      # Generate test data
      data_csv_path = generate_data(
          input_features,
          output_features,
          os.path.join(tmpdir, csv_filename),
          num_examples=100,
      )
  
      config = {
          "input_features": input_features,
          "output_features": output_features,
          "trainer": {
              "epochs": 5,
              "batch_size": 32,
              "evaluate_training_set": True,  # needed to ensure exact training metrics computed
          },
      }
  
      model = LudwigModel(
          config=config,
      )
  
      training_stats, _, _ = model.train(
          training_set=data_csv_path, random_seed=1919
      )
  
      # generate predicitons from training data
      df = pd.read_csv(data_csv_path)
      predictions = model.predict(df)
  
      # compute loss on predictions from training data
      loss_function = MSELoss(MSELossConfig())
      loss = loss_function(
          torch.tensor(
              predictions[0][
                  output_feature_name + "_predictions"
              ].values
          ),  # predictions
          torch.tensor(df[output_feature_name].values),  # target
      ).type(torch.float32)
  
      # get last loss value from training
      last_training_loss = torch.tensor(
          training_stats[TRAINING][output_feature_name][LOSS][-1]
      )
  
      # loss from predictions should match last loss value recorded during training
      assert torch.isclose(loss, last_training_loss), (
          "Model predictions on training set did not generate same loss value as in training. "
          "Need to confirm that weights were correctly captured in model."
      )
  
file_path: ludwig/tests/integration_tests/test_model_save_and_load.py
imports: import os
  import os.path
  import random
  import numpy
  import pandas
  import pytest
  import torch
  from ludwig.api import LudwigModel
  from ludwig.constants import BATCH_SIZE, ENCODER, LOSS, NAME, PREPROCESSING, TRAINER, TRAINING, TYPE
  from ludwig.data.split import get_splitter
  from ludwig.modules.loss_modules import MSELoss
  from ludwig.schema.features.loss.loss import MSELossConfig
  from ludwig.utils.data_utils import read_csv
  from tests.integration_tests.utils import audio_feature, bag_feature, binary_feature, category_feature, date_feature, generate_data, h3_feature, image_feature, LocalTestBackend, number_feature, sequence_feature, set_feature, text_feature, timeseries_feature, vector_feature
label_desc: Use image node_id 3 for calling a global function with example usage: test_model_weights_match_training(tmpdir, csv_filename) without return types