def _check_invalid_tensor_rank(self):
        """
        Check if the program consists of tensors with rank >= 6.
        """
        def _check_invalid_tensor_rank_block(block):
            for op in block.operations:
                for b in op.blocks:
                    _check_invalid_tensor_rank_block(b)
                for o in op.outputs:
                    if not isinstance(o, ListVar) and (o.rank < 0 or o.rank >= 6):
                        if op.op_type == "const" or op.op_type.startswith("constexpr_"):
                            if all(
                                child_op.op_type.startswith("constexpr_")
                                for child_op in o.child_ops
                            ):
                                # For const/constexpr op's constexpr output, tensor with rank > 5 is ok.
                                continue
                        raise ValueError(
                            f'Core ML only supports tensors with rank <= 5. Layer "{op.name}", '
                            f'with type "{op.op_type}", outputs a rank {o.rank} tensor. '
                        )

        for f in self.functions.values():
            _check_invalid_tensor_rank_block(f)

        Check if the program consists of tensors with rank >= 6.
        
coremltools/converters/mil/mil/program.py