code: def get_prev_names(all_layers, current_layer):
      prev_names = []
      for layer in all_layers:
          if layer is current_layer:
              break
  
          # The following if-statement is needed to handle the case where the
          # the layer is an 'existing' layer, derived from an existing trained
          # neural network supplied via the existing-model option, that we are
          # adding layers to. In this case, these layers are not considered as
          # layers preceding 'current_layer'.
          if layer.layer_type is not "existing":
              prev_names.append(layer.get_name())
      prev_names_set = set()
      for name in prev_names:
          if name in prev_names_set:
              raise RuntimeError(
                  "{0}: Layer name {1} is used more than once.".format(
                      sys.argv[0], name
                  )
              )
          prev_names_set.add(name)
      return prev_names
  
imports: from __future__ import print_function
  from __future__ import division
  import re
  import sys
label_desc: Use image node_id 1 for calling a global function with example usage: get_prev_names(all_layers, current_layer) and returns: prev_names