code: def borrow_cached_network(klass, network_json, network_weights):
          
          assert network_weights is not None
          key = klass.keras_network_cache_key(network_json)
          if key not in klass.KERAS_MODELS_CACHE:
              # Cache miss.
              import keras.models
              network = keras.models.model_from_json(network_json)
              existing_weights = None
          else:
              # Cache hit.
              (network, existing_weights) = klass.KERAS_MODELS_CACHE[key]
          if existing_weights is not network_weights:
              network.set_weights(network_weights)
              klass.KERAS_MODELS_CACHE[key] = (network, network_weights)
  
          # As an added safety check we overwrite the fit method on the returned
          # model to throw an error if it is called.
          def throw(*args, **kwargs):
              raise NotImplementedError("Do not call fit on cached model.")
  
          network.fit = throw
          return network
docs: Return a keras Model with the specified architecture and weights.
          As an optimization, when possible this will reuse architectures from a
          process-wide cache.
  
          The returned object is "borrowed" in the sense that its weights can
          change later after subsequent calls to this method from other objects.
  
          If you're using this from a parallel implementation you'll need to
          hold a lock while using the returned object.
  
          Parameters
          ----------
          network_json : string of JSON
          network_weights : list of numpy.array
  
          Returns
          -------
          keras.models.Model