code: def test_bad_python_to_cpp_casts(m):
      with pytest.raises(
          TypeError,
          match=r"^round_trip_tensor\(\): incompatible function arguments",
      ):
          m.round_trip_tensor(np.zeros((2, 3)))
  
      with pytest.raises(
          TypeError, match=r"^Cannot cast array data from dtype"
      ):
          m.round_trip_tensor(np.zeros(dtype=np.str_, shape=(2, 3, 1)))
  
      with pytest.raises(
          TypeError,
          match=r"^round_trip_tensor_noconvert\(\): incompatible function arguments",
      ):
          m.round_trip_tensor_noconvert(tensor_ref)
  
      assert_equal_tensor_ref(
          m.round_trip_tensor_noconvert(tensor_ref.astype(np.float64))
      )
  
      if m.needed_options == "F":
          bad_options = "C"
      else:
          bad_options = "F"
      # Shape, dtype and the order need to be correct for a TensorMap cast
      with pytest.raises(
          TypeError,
          match=r"^round_trip_view_tensor\(\): incompatible function arguments",
      ):
          m.round_trip_view_tensor(
              np.zeros((3, 5, 2), dtype=np.float64, order=bad_options)
          )
  
      with pytest.raises(
          TypeError,
          match=r"^round_trip_view_tensor\(\): incompatible function arguments",
      ):
          m.round_trip_view_tensor(
              np.zeros(
                  (3, 5, 2), dtype=np.float32, order=m.needed_options
              )
          )
  
      with pytest.raises(
          TypeError,
          match=r"^round_trip_view_tensor\(\): incompatible function arguments",
      ):
          m.round_trip_view_tensor(
              np.zeros((3, 5), dtype=np.float64, order=m.needed_options)
          )
  
      with pytest.raises(
          TypeError,
          match=r"^round_trip_view_tensor\(\): incompatible function arguments",
      ):
          temp = np.zeros(
              (3, 5, 2), dtype=np.float64, order=m.needed_options
          )
          m.round_trip_view_tensor(
              temp[:, ::-1, :],
          )
  
      with pytest.raises(
          TypeError,
          match=r"^round_trip_view_tensor\(\): incompatible function arguments",
      ):
          temp = np.zeros(
              (3, 5, 2), dtype=np.float64, order=m.needed_options
          )
          temp.setflags(write=False)
          m.round_trip_view_tensor(temp)
  
file_path: coremltools/deps/pybind11/tests/test_eigen_tensor.py
imports: import sys
  import pytest
label_desc: Use image node_id 7 for calling a global function with example usage: test_bad_python_to_cpp_casts(m) without return types