code: def get_layer_from_config(
      old_layer: Layer,
      new_config: dict[str, Any],
      weights: list[np.ndarray] | list[Tensor] | None = None,
      reuse_symbolic_tensors: bool = True,
  ) -> Layer:
      """Creates a new layer from a config
  
      Creates a new layer given a changed config and weights etc.
  
      :param old_layer: A layer that shall be used as base.
      :param new_config: The config to create the new layer.
      :param weights: Weights to set in the new layer.
        Options: np tensors, symbolic tensors, or None,
        in which case the weights from old_layers are used.
      :param reuse_symbolic_tensors: If the weights of the
        old_layer are used copy the symbolic ones or copy
        the Numpy weights.
      :return: The new layer instance.
      """
      new_layer = old_layer.__class__.from_config(new_config)
  
      if weights is None:
          if reuse_symbolic_tensors:
              weights = old_layer.weights
          else:
              weights = old_layer.get_weights()
  
      if len(weights) > 0:
          input_shapes = old_layer.get_input_shape_at(0)
          # todo: inspect and set initializers to something fast for speedup
          new_layer.build(input_shapes)
  
          is_np_weight = [isinstance(x, np.ndarray) for x in weights]
          if all(is_np_weight):
              new_layer.set_weights(weights)
          else:
              if any(is_np_weight):
                  raise ValueError(
                      "Expect either all weights to be "
                      "np tensors or symbolic tensors."
                  )
  
              symbolic_names = get_symbolic_weight_names(old_layer)
              update = dict(zip(symbolic_names, weights))
              update_symbolic_weights(new_layer, update)
  
      return new_layer
  
imports: from __future__ import annotations
  import inspect
  import warnings
  from abc import ABCMeta, abstractmethod
  from typing import Any, Callable
  import numpy
  import tensorflow.keras.backend
  import tensorflow.keras.layers
  import tensorflow.keras.models
  import innvestigate.backend
  import innvestigate.backend.checks
  import innvestigate.layers
  from innvestigate.backend.types import Layer, LayerCheck, Model, NodeDict, OptionalList, ReverseTensorDict, Tensor
label_desc: Use image node_id 6 for calling a global function with example usage: get_layer_from_config(old_layer, new_config, weights, reuse_symbolic_tensors) and returns: new_layer