code: def structured_to_unstructured(
      arr, dtype=None, copy=False, casting="unsafe"
  ):
      """
      Converts and n-D structured array into an (n+1)-D unstructured array.
  
      The new array will have a new last dimension equal in size to the
      number of field-elements of the input array. If not supplied, the output
      datatype is determined from the numpy type promotion rules applied to all
      the field datatypes.
  
      Nested fields, as well as each element of any subarray fields, all count
      as a single field-elements.
  
      Parameters
      ----------
      arr : ndarray
         Structured array or dtype to convert. Cannot contain object datatype.
      dtype : dtype, optional
         The dtype of the output unstructured array.
      copy : bool, optional
          See copy argument to `ndarray.astype`. If true, always return a copy.
          If false, and `dtype` requirements are satisfied, a view is returned.
      casting : {'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optional
          See casting argument of `ndarray.astype`. Controls what kind of data
          casting may occur.
  
      Returns
      -------
      unstructured : ndarray
         Unstructured array with one more dimension.
  
      Examples
      --------
  
      >>> from numpy.lib import recfunctions as rfn
      >>> a = np.zeros(4, dtype=[('a', 'i4'), ('b', 'f4,u2'), ('c', 'f4', 2)])
      >>> a
      array([(0, (0., 0), [0., 0.]), (0, (0., 0), [0., 0.]),
             (0, (0., 0), [0., 0.]), (0, (0., 0), [0., 0.])],
            dtype=[('a', '<i4'), ('b', [('f0', '<f4'), ('f1', '<u2')]), ('c', '<f4', (2,))])
      >>> rfn.structured_to_unstructured(a)
      array([[0., 0., 0., 0., 0.],
             [0., 0., 0., 0., 0.],
             [0., 0., 0., 0., 0.],
             [0., 0., 0., 0., 0.]])
  
      >>> b = np.array([(1, 2, 5), (4, 5, 7), (7, 8 ,11), (10, 11, 12)],
      ...              dtype=[('x', 'i4'), ('y', 'f4'), ('z', 'f8')])
      >>> np.mean(rfn.structured_to_unstructured(b[['x', 'z']]), axis=-1)
      array([ 3. ,  5.5,  9. , 11. ])
  
      """
      if arr.dtype.names is None:
          raise ValueError("arr must be a structured array")
  
      fields = _get_fields_and_offsets(arr.dtype)
      n_fields = len(fields)
      if n_fields == 0 and dtype is None:
          raise ValueError("arr has no fields. Unable to guess dtype")
      elif n_fields == 0:
          # too many bugs elsewhere for this to work now
          raise NotImplementedError(
              "arr with no fields is not supported"
          )
  
      dts, counts, offsets = zip(*fields)
      names = ["f{}".format(n) for n in range(n_fields)]
  
      if dtype is None:
          out_dtype = np.result_type(*[dt.base for dt in dts])
      else:
          out_dtype = dtype
  
      # Use a series of views and casts to convert to an unstructured array:
  
      # first view using flattened fields (doesn't work for object arrays)
      # Note: dts may include a shape for subarrays
      flattened_fields = np.dtype(
          {
              "names": names,
              "formats": dts,
              "offsets": offsets,
              "itemsize": arr.dtype.itemsize,
          }
      )
      with suppress_warnings() as sup:  # until 1.16 (gh-12447)
          sup.filter(FutureWarning, "Numpy has detected")
          arr = arr.view(flattened_fields)
  
      # next cast to a packed format with all fields converted to new dtype
      packed_fields = np.dtype(
          {
              "names": names,
              "formats": [(out_dtype, dt.shape) for dt in dts],
          }
      )
      arr = arr.astype(packed_fields, copy=copy, casting=casting)
  
      # finally is it safe to view the packed fields as the unstructured type
      return arr.view((out_dtype, (sum(counts),)))
  
imports: from __future__ import division, absolute_import, print_function
  import sys
  import itertools
  import numpy
  import numpy.ma
  from numpy import ndarray, recarray
  from numpy.ma import MaskedArray
  from numpy.ma.mrecords import MaskedRecords
  from numpy.core.overrides import array_function_dispatch
  from numpy.lib._iotools import _is_string_like
  from numpy.compat import basestring
  from numpy.testing import suppress_warnings
label_desc: Use image node_id 32 for calling a global function with example usage: structured_to_unstructured(arr, dtype, copy, casting) and returns: arr