code: def test_structured_field_offsets(self, to_dt, expected_off):
      # This checks the cast-safety and view offset for swapped and "shifted"
      # fields which are viewable
      from_dt = np.dtype(
          {
              "names": ["a", "b"],
              "formats": ["i4", "f4"],
              "offsets": [2, 6],
          }
      )
      cast = get_castingimpl(type(from_dt), type(to_dt))
      safety, _, view_off = cast._resolve_descriptors((from_dt, to_dt))
      if from_dt.names == to_dt.names:
          assert safety == Casting.equiv
      else:
          assert safety == Casting.safe
      # Shifting the original data pointer by -2 will align both by
      # effectively adding 2 bytes of spacing before `from_dt`.
      assert view_off == expected_off
  
imports: import pytest
  import textwrap
  import enum
  import random
  import ctypes
  import numpy
  from numpy.lib.stride_tricks import as_strided
  from numpy.testing import assert_array_equal
  from numpy.core._multiarray_umath import _get_castingimpl
label_desc: Use image node_id 17 for calling the TestCasting obj's underlying member method code with example usage: obj.test_structured_field_offsets(to_dt, expected_off) without return types