code: def test_BaggingEnsemble_fit():
      tf.keras.backend.clear_session()
  
      train_data = np.array([1, 2])
      train_targets = np.array([[1, 0], [0, 1]])
  
      graph = example_graph_1(feature_size=10)
  
      # base_model, keras_model, generator, train_gen
      gnn_models = [
          create_graphSAGE_model(graph),
          create_HinSAGE_model(graph),
          create_GCN_model(graph),
          create_GAT_model(graph),
      ]
  
      for gnn_model in gnn_models:
          keras_model = gnn_model[1]
          generator = gnn_model[2]
          train_gen = gnn_model[3]
  
          ens = BaggingEnsemble(
              keras_model, n_estimators=2, n_predictions=1
          )
  
          ens.compile(
              optimizer=Adam(),
              loss=categorical_crossentropy,
              weighted_metrics=["acc"],
          )
  
          ens.fit(
              generator=generator,
              train_data=train_data,
              train_targets=train_targets,
              epochs=1,
              validation_data=train_gen,
              verbose=0,
              shuffle=False,
          )
  
          # This is a BaggingEnsemble so the generator in the below call is of the wrong type.
          with pytest.raises(ValueError):
              ens.fit(
                  train_gen,
                  train_data=train_data,
                  train_targets=train_targets,
                  epochs=10,
                  verbose=0,
                  shuffle=False,
              )
  
          with pytest.raises(ValueError):
              ens.fit(
                  generator=generator,
                  train_data=train_data,
                  train_targets=None,  # Should not be None
                  epochs=10,
                  validation_data=train_gen,
                  verbose=0,
                  shuffle=False,
              )
  
          with pytest.raises(ValueError):
              ens.fit(
                  generator=generator,
                  train_data=None,
                  train_targets=None,
                  epochs=10,
                  validation_data=None,
                  verbose=0,
                  shuffle=False,
              )
  
          with pytest.raises(ValueError):
              ens.fit(
                  generator=generator,
                  train_data=train_data,
                  train_targets=train_targets,
                  epochs=10,
                  validation_data=None,
                  verbose=0,
                  shuffle=False,
                  bag_size=-1,  # should be positive integer smaller than or equal to len(train_data) or None
              )
  
          with pytest.raises(ValueError):
              ens.fit(
                  generator=generator,
                  train_data=train_data,
                  train_targets=train_targets,
                  epochs=10,
                  validation_data=None,
                  verbose=0,
                  shuffle=False,
                  bag_size=10,  # larger than the number of training points
              )
  
imports: import pandas
  import pytest
  import numpy
  import tensorflow
  from stellargraph import StellarGraph
  from stellargraph.layer import GraphSAGE, GCN, GAT, HinSAGE, link_classification, link_regression
  from stellargraph.mapper import GraphSAGENodeGenerator, FullBatchNodeGenerator, HinSAGENodeGenerator, GraphSAGELinkGenerator, HinSAGELinkGenerator
  from stellargraph.ensemble import Ensemble, BaggingEnsemble
  from tensorflow.keras import layers, Model
  from tensorflow.keras.optimizers import Adam
  from tensorflow.keras.losses import categorical_crossentropy, binary_crossentropy
label_desc: Use image node_id 9 for calling a global function with example usage: test_BaggingEnsemble_fit() without return types