code: def test_safe_dtype():
      pytest.raises(TypeError, safe_dtype, str)
      pytest.raises(TypeError, safe_dtype, str, np.float64)
      pytest.raises(TypeError, safe_dtype, [("x", "f8")])
      valid_dtypes = []
      valid_dtypes.extend(np.sctypes["complex"])
      valid_dtypes.extend(np.sctypes["float"])
      valid_dtypes.extend(np.sctypes["int"])
      valid_dtypes.extend(np.sctypes["uint"])
      for dt in valid_dtypes:
          sdt = safe_dtype(dt)
          assert sdt == dt
      # test a few upcastings
      dt = safe_dtype(np.float32, np.int16, np.bool_)
      assert dt == np.float32
      dt = safe_dtype(np.float32, np.int64, np.uint32)
      assert dt == np.float64
      # test byteswapped types - isbuiltin will be false
      orig_dt = np.dtype("f")
      dt = safe_dtype(orig_dt, np.int64, np.uint32)
      assert dt == np.float64
      swapped_dt = orig_dt.newbyteorder()
      dt = safe_dtype(swapped_dt, np.int64, np.uint32)
      assert dt == np.float64
  
imports: from types import SimpleNamespace
  import numpy
  import pytest
  from ..coordinate_system import CoordinateSystem, CoordinateSystemError, CoordSysMaker, CoordSysMakerError, is_coordsys, is_coordsys_maker, product, safe_dtype
label_desc: Use image node_id 15 for calling a global function with example usage: test_safe_dtype() without return types