code: def run_layer(config):
      """
      Each `config` is a dictionary with the form:
      {
          "layer": class,
          "modes": list[int],
          "kwargs": dict,
          "dense": bool,
          "sparse": bool,
          "edges": bool
      },
  
      "layer" is the class of the layer to be tested.
  
      "modes" is a list containing the data modes supported by the model, as specified by
      the global MODES dictionary in this file.
  
      "kwargs" is a dictionary containing all keywords to be passed to the layer
      (including mandatory ones).
  
      "dense" is True if the layer supports dense adjacency matrices.
  
      "sparse" is True if the layer supports sparse adjacency matrices.
  
      "edges" is True if the layer supports edge attributes.
  
      The testing loop will create a simple 1-layer Model and run it in single, mixed,
      and batch mode according the what specified in the testing config.
  
      The loop will check:
          - that the model does not crash;
          - that the output shape is pre-computed correctly;
          - that the real output shape is correct;
          - that the get_config() method works correctly (i.e., it is possible to
            re-instatiate a layer using LayerClass(**layer_instance.get_config())).
      """
      for mode in config["modes"]:
          if mode == MODES["SINGLE"]:
              if config["dense"]:
                  _test_single_mode(
                      config["layer"],
                      sparse=False,
                      edges=config.get("edges", False),
                      **config["kwargs"],
                  )
              if config["sparse"]:
                  _test_single_mode(
                      config["layer"],
                      sparse=True,
                      edges=config.get("edges", False),
                      **config["kwargs"],
                  )
          elif mode == MODES["BATCH"]:
              _test_batch_mode(
                  config["layer"],
                  edges=config.get("edges", False),
                  **config["kwargs"],
              )
          elif mode == MODES["MIXED"]:
              if config["dense"]:
                  _test_mixed_mode(
                      config["layer"],
                      sparse=False,
                      edges=config.get("edges", False),
                      **config["kwargs"],
                  )
              if config["sparse"]:
                  _test_mixed_mode(
                      config["layer"],
                      sparse=True,
                      edges=config.get("edges", False),
                      **config["kwargs"],
                  )
      _test_get_config(config["layer"], **config["kwargs"])
      _test_preprocess(config["layer"])
  
      for k, v in config["kwargs"].items():
          if k.endswith("_initializer"):
              config["kwargs"][k] = "zeros"
      config["kwargs"]["kernel_initializer"] = "zeros"
  
      if config["dense"]:
          _test_dtype_compatibility(
              config["layer"],
              sparse=False,
              edges=config.get("edges", False),
              **config["kwargs"],
          )
      if config["sparse"]:
          _test_dtype_compatibility(
              config["layer"],
              sparse=True,
              edges=config.get("edges", False),
              **config["kwargs"],
          )
  
file_path: spektral/tests/test_layers/convolutional/core.py
imports: import itertools
  import numpy
  import tensorflow
  from tensorflow.keras import Input, Model
  from spektral.utils.sparse import sp_matrix_to_sp_tensor
label_desc: Use image node_id 8 for calling a global function with example usage: run_layer(config) without return types