class_docstr: Test the basic error handling / validation in pymil.
class_docstr_tok: ["Test","the","basic","error","handling","\/","validation","in","pymil","."]
docstr: The builder should error out early when detecting a list of rank 5 (or higher) tensors is created
docstr_tok: ["The","builder","should","error","out","early","when","detecting","a","list","of","rank","5","(","or","higher",")","tensors","is","created"]
code: def test_rank5_list_early_error_out():
      """
      The builder should error out early when detecting a list of rank 5 (or higher) tensors is created
      """
      expected_err_str = 'Core ML only supports list of elements with rank <= 4. Layer "list_0", with type "make_list", outputs a list of rank 5 tensors.'
      with pytest.raises(ValueError, match=expected_err_str):
  
          @mb.program(
              input_specs=[mb.TensorSpec(shape=(1,), dtype=types.fp32)]
          )
          def prog(x):
              ls = mb.make_list(
                  init_length=1,
                  dtype="fp32",
                  elem_shape=(1, 1, 1, 1, 1),
                  dynamic_length=True,
                  name="list_0",
              )
              return ls
  
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 5 for calling the TestMILBasic obj's underlying member method code with example usage: obj.test_rank5_list_early_error_out() and returns: ls