code: def test_internal_layer(self):
      np.random.seed(1988)
  
      input_dim = 5
      num_channels1 = 10
      num_channels2 = 7
      num_channels3 = 5
  
      w1 = (np.random.rand(input_dim, num_channels1) - 0.5) / 5.0
      w2 = (np.random.rand(num_channels1, num_channels2) - 0.5) / 5.0
      w3 = (np.random.rand(num_channels2, num_channels3) - 0.5) / 5.0
  
      b1 = (
          np.random.rand(
              num_channels1,
          )
          - 0.5
      ) / 5.0
      b2 = (
          np.random.rand(
              num_channels2,
          )
          - 0.5
      ) / 5.0
      b3 = (
          np.random.rand(
              num_channels3,
          )
          - 0.5
      ) / 5.0
  
      model = Sequential()
      model.add(Dense(num_channels1, input_dim=input_dim))
      model.add(Dense(num_channels2, name="middle_layer"))
      model.add(Dense(num_channels3))
  
      model.set_weights([w1, b1, w2, b2, w3, b3])
  
      input_names = ["input"]
      output_names = ["output"]
      coreml1 = keras_converter.convert(
          model, input_names, output_names
      )
  
      # adjust the output parameters of coreml1 to include the intermediate layer
      spec = coreml1.get_spec()
      coremlNewOutputs = spec.description.output.add()
      coremlNewOutputs.name = "middle_layer_output"
      coremlNewParams = coremlNewOutputs.type.multiArrayType
      coremlNewParams.dataType = coremltools.proto.FeatureTypes_pb2.ArrayFeatureType.ArrayDataType.Value(
          "DOUBLE"
      )
      coremlNewParams.shape.extend([num_channels2])
  
      coremlfinal = coremltools.models.MLModel(spec)
  
      # generate a second model which
      model2 = Sequential()
      model2.add(Dense(num_channels1, input_dim=input_dim))
      model2.add(Dense(num_channels2))
      model2.set_weights([w1, b1, w2, b2])
  
      coreml2 = keras_converter.convert(
          model2, input_names, ["output2"]
      )
  
      if _is_macos() and _macos_version() >= (10, 13):
          # generate input data
          inputs = np.random.rand(input_dim)
  
          fullOutputs = coremlfinal.predict({"input": inputs})
  
          partialOutput = coreml2.predict({"input": inputs})
  
          for i in range(0, num_channels2):
              self.assertAlmostEquals(
                  fullOutputs["middle_layer_output"][i],
                  partialOutput["output2"][i],
                  2,
              )
  
imports: import unittest
  import numpy
  import tempfile
  import pytest
  import shutil
  import os
  import coremltools
  from coremltools._deps import _HAS_KERAS_TF, MSG_KERAS1_NOT_FOUND
  from coremltools._deps import _HAS_TF, MSG_TF1_NOT_FOUND
  from coremltools.models.utils import _get_custom_layer_names, _replace_custom_layer_name, _macos_version, _is_macos
  from coremltools.proto import Model_pb2
label_desc: Use image node_id 3 for calling the KerasBasicNumericCorrectnessTest obj's underlying member method code with example usage: obj.test_internal_layer() without return types