class_docstr: Test the basic error handling / validation in pymil.
class_docstr_tok: ["Test","the","basic","error","handling","\/","validation","in","pymil","."]
docstr: The converter should early error out if dialect opset is detected in the pymil program.
docstr_tok: ["The","converter","should","early","error","out","if","dialect","opset","is","detected","in","the","pymil","program","."]
code: def test_invalid_dialect_namespaces_error_out():
      """
      The converter should early error out if dialect opset is detected in the pymil program.
      """
  
      # The pymil program of torch dialect opset cannot be lowered to backend
      @mb.program(
          input_specs=[
              mb.TensorSpec(shape=(2, 2, 3, 4), dtype=types.fp32)
          ]
      )
      def prog(x):
          return mb.torch_upsample_nearest_neighbor(
              x=x, output_height=10, output_width=5, name="op_1"
          )
  
      expected_err_str = 'Core ML only support core opset. Got unsupported op "op_1" with type "torch_upsample_nearest_neighbor" of dialect namespace "torch".'
      with pytest.raises(ValueError, match=expected_err_str):
          ct.convert(
              prog,
              convert_to="mlprogram",
              pass_pipeline=ct.PassPipeline.EMPTY,
          )
  
imports: import numpy
  import pytest
  import coremltools
  from coremltools import _logger
  from coremltools.converters.mil.mil import Builder
  from coremltools.converters.mil.mil import Function, Program, types
  from coremltools.converters.mil.mil.passes.tests.test_passes import CONSTEXPR_FUNCS
label_desc: Use image node_id 3 for calling the TestMILBasic obj's underlying member method code with example usage: obj.test_invalid_dialect_namespaces_error_out() and returns: mb