code: def test_conv_example():
      batch, C_in, C_out, H, W = 2, 2, 3, 7, 10
      kH, kW = 3, 5
      img_shape, seq_shape = (batch, C_in, H, W), (batch, C_in, H)
  
      @mb.program(
          input_specs=[
              mb.TensorSpec(shape=img_shape),
              mb.TensorSpec(shape=seq_shape),
          ]
      )
      def prog(img, seq):
          ## 2D convolution
          # Weight
          W_2d = np.random.rand(C_out, C_in, kH, kW).astype(np.float32)
          W_2d = mb.const(val=W_2d, mode="file_value", name="const_W")
  
          # Test 1: provide only required arguments.
          conv1 = mb.conv(x=img, weight=W_2d, pad_type="valid")
          logging.info("conv1 shape: {}".format(conv1.shape))
  
          # Test 2: stride > 1
          conv2 = mb.conv(
              x=img, weight=W_2d, pad_type="valid", strides=[2, 3]
          )
          logging.info("conv2 shape: {}".format(conv2.shape))
  
          # Test 3: same padding
          conv3 = mb.conv(
              x=img, weight=W_2d, pad_type="same", strides=[2, 3]
          )
          logging.info("conv3 shape: {}".format(conv3.shape))
  
          # Test max_pool
          pool1 = mb.max_pool(
              x=img,
              kernel_sizes=[kH, kW],
              pad_type="valid",
              strides=[2, 3],
          )
          logging.info("pool1 shape: {}".format(pool1.shape))
  
          # Test max_pool
          pool2 = mb.max_pool(
              x=img,
              kernel_sizes=[kH, kW],
              pad_type="same",
              strides=[2, 3],
          )
          logging.info("pool2 shape: {}".format(pool2.shape))
  
          ## 1D convolution
          W_1d = np.random.rand(C_out, C_in, kH).astype(np.float32)
          W_1d = mb.const(
              val=W_1d, mode="file_value", name="const_W_1d"
          )
          logging.info("W_1d val: {}".format(W_1d.val))
  
          # Test 4: provide only required arguments for 1D.
          conv4 = mb.conv(x=seq, weight=W_1d, pad_type="valid")
  
          logging.info("conv4 shape: {}".format(conv4.shape))
  
          return conv1, conv2, conv3, pool1, pool2, conv4
  
      proto = converter._convert(
          prog, convert_from="mil", convert_to="nn_proto"
      )
  
      feed_dict = {
          "img": np.random.rand(*img_shape).astype(np.float32),
          "seq": np.random.rand(*seq_shape).astype(np.float32),
      }
      model = models.MLModel(proto)
      assert model is not None
  
      if ct.utils._is_macos():
          prediction = model.predict(feed_dict)
          assert len(prediction) == 6
  
file_path: turicreate/src/external/coremltools_wrap/coremltools/coremltools/converters/mil/mil/tests/test_programs.py
imports: from __future__ import print_function
  from __future__ import division
  from __future__ import absolute_import
  import pytest
  import coremltools
  from coremltools import models
  import numpy
  from coremltools.converters.mil.mil import Builder
  from coremltools.converters.mil import converter
  import logging
label_desc: Use image node_id 2 for calling a global function with example usage: test_conv_example() and returns: conv1,  conv2,  conv3,  pool1,  pool2,  conv4