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: from collections.abc import Iterable
  from functools import lru_cache
  import math
  import os
  import shutil
  import subprocess
  import sys
  import tempfile
  from typing import Optional, Union
  import warnings
  import numpy
  import coremltools
  from coremltools import ComputeUnit
  from coremltools.converters.mil.mil.passes.defs.preprocess import NameSanitizer
  from coremltools.proto import Model_pb2
  import coremltools.proto.MIL_pb2
  from .._deps import _HAS_SCIPY
label_desc: Use image node_id 6 for calling a global function with example usage: _get_nn_layers(spec) and returns: layers, _get_nn_layers, _get_nn_layers