code: def _get_nn_layers(spec):
      """
      Returns a list of neural network layers if the model contains any.
  
      Parameters
      ----------
      spec: Model_pb
          A model protobuf specification.
  
      Returns
      -------
      [NN layer]
          list of all layers (including layers from elements of a pipeline
  
      """
  
      layers = []
      if spec.WhichOneof("Type") == "pipeline":
          layers = []
          for model_spec in spec.pipeline.models:
              if not layers:
                  return _get_nn_layers(model_spec)
              else:
                  layers.extend(_get_nn_layers(model_spec))
  
      elif spec.WhichOneof("Type") in [
          "pipelineClassifier",
          "pipelineRegressor",
      ]:
          layers = []
          for model_spec in spec.pipeline.models:
              if not layers:
                  return _get_nn_layers(model_spec)
              else:
                  layers.extend(_get_nn_layers(model_spec))
  
      elif spec.neuralNetwork.layers:
          layers = spec.neuralNetwork.layers
      elif spec.neuralNetworkClassifier.layers:
          layers = spec.neuralNetworkClassifier.layers
      elif spec.neuralNetworkRegressor.layers:
          layers = spec.neuralNetworkRegressor.layers
  
      return layers
  
imports: import math
  import numpy
  import os
  import six
  import warnings
  import sys
  from coremltools.proto import Model_pb2
  from coremltools.models._deprecation import deprecated
  from .._deps import _HAS_SKLEARN
label_desc: Use image node_id 4 for calling a global function with example usage: _get_nn_layers(spec) and returns: layers, _get_nn_layers, _get_nn_layers