code: def from_numpy_dtype(dtype):
      """Convert NumPy datatype to MPI datatype."""
      try:
          dtype = _np_dtype(dtype)
      except NameError:
          raise RuntimeError("NumPy is not available") from None
  
      if dtype.hasobject:
          raise ValueError("NumPy datatype with object entries")
      if not dtype.isnative:
          raise ValueError("NumPy datatype with non-native byteorder")
  
      # struct data type
      fields = dtype.fields
      if fields:
          blocklengths = []
          displacements = []
          datatypes = []
          try:
              for name in dtype.names:
                  ftype, fdisp = fields[name]
                  blocklengths.append(1)
                  displacements.append(fdisp)
                  datatypes.append(from_numpy_dtype(ftype))
              datatype = MPI.Datatype.Create_struct(
                  blocklengths,
                  displacements,
                  datatypes,
              )
          finally:
              for mtp in datatypes:
                  mtp.Free()
          try:
              return datatype.Create_resized(0, dtype.itemsize)
          finally:
              datatype.Free()
  
      # subarray data type
      subdtype = dtype.subdtype
      if subdtype:
          base, shape = subdtype
          datatype = from_numpy_dtype(base)
          try:
              if len(shape) == 1:
                  return datatype.Create_contiguous(shape[0])
              starts = (0,) * len(shape)
              return datatype.Create_subarray(shape, shape, starts)
          finally:
              datatype.Free()
  
      # elementary data type
      datatype = _get_datatype(dtype)
      return datatype.Dup()
  
imports: from ..None import MPI
label_desc: Use image node_id 5 for calling a global function with example usage: from_numpy_dtype(dtype) and returns: datatype, datatype, datatype, datatype