code: def prepare_networks(
      encoder,
      decoder,
      n_components,
      dims,
      n_data,
      parametric_embedding,
      parametric_reconstruction,
      init_embedding=None,
  ):
      """
      Generates a set of keras networks for the encoder and decoder if one has not already
      been predefined.
  
      Parameters
      ----------
      encoder : tf.keras.Sequential
          The encoder Keras network
      decoder : tf.keras.Sequential
          the decoder Keras network
      n_components : int
          the dimensionality of the latent space
      dims : tuple of shape (dim1, dim2, dim3...)
          dimensionality of data
      n_data : number of elements in dataset
          # of elements in training dataset
      parametric_embedding : bool
          Whether the embedder is parametric or non-parametric
      parametric_reconstruction : bool
          Whether the decoder is parametric or non-parametric
      init_embedding : array (optional, default None)
          The initial embedding, for nonparametric embeddings
  
      Returns
      -------
      encoder: tf.keras.Sequential
          encoder keras network
      decoder: tf.keras.Sequential
          decoder keras network
      """
  
      if parametric_embedding:
          if encoder is None:
              encoder = tf.keras.Sequential(
                  [
                      tf.keras.layers.InputLayer(input_shape=dims),
                      tf.keras.layers.Flatten(),
                      tf.keras.layers.Dense(
                          units=100, activation="relu"
                      ),
                      tf.keras.layers.Dense(
                          units=100, activation="relu"
                      ),
                      tf.keras.layers.Dense(
                          units=100, activation="relu"
                      ),
                      tf.keras.layers.Dense(
                          units=n_components, name="z"
                      ),
                  ]
              )
      else:
          embedding_layer = tf.keras.layers.Embedding(
              n_data, n_components, input_length=1
          )
          embedding_layer.build(input_shape=(1,))
          embedding_layer.set_weights([init_embedding])
          encoder = tf.keras.Sequential([embedding_layer])
  
      if decoder is None:
          if parametric_reconstruction:
              decoder = tf.keras.Sequential(
                  [
                      tf.keras.layers.InputLayer(
                          input_shape=n_components
                      ),
                      tf.keras.layers.Dense(
                          units=100, activation="relu"
                      ),
                      tf.keras.layers.Dense(
                          units=100, activation="relu"
                      ),
                      tf.keras.layers.Dense(
                          units=100, activation="relu"
                      ),
                      tf.keras.layers.Dense(
                          units=np.product(dims),
                          name="recon",
                          activation=None,
                      ),
                      tf.keras.layers.Reshape(dims),
                  ]
              )
  
      return encoder, decoder
  
imports: import numpy
  from umap import UMAP
  from warnings import warn, catch_warnings, filterwarnings
  from numba import TypingError
  import os
  from umap.spectral import spectral_layout
  from sklearn.utils import check_random_state
  import codecs, pickle
  from sklearn.neighbors import KDTree
  import sys
label_desc: Use image node_id 7 for calling a global function with example usage: prepare_networks(encoder, decoder, n_components, dims, n_data, parametric_embedding, parametric_reconstruction, init_embedding) and returns: encoder,  decoder