code: def __dtype_from_pep3118(stream, is_subdtype):
      field_spec = dict(names=[], formats=[], offsets=[], itemsize=0)
      offset = 0
      common_alignment = 1
      is_padding = False
  
      # Parse spec
      while stream:
          value = None
  
          # End of structure, bail out to upper level
          if stream.consume("}"):
              break
  
          # Sub-arrays (1)
          shape = None
          if stream.consume("("):
              shape = stream.consume_until(")")
              shape = tuple(map(int, shape.split(",")))
  
          # Byte order
          if stream.next in ("@", "=", "<", ">", "^", "!"):
              byteorder = stream.advance(1)
              if byteorder == "!":
                  byteorder = ">"
              stream.byteorder = byteorder
  
          # Byte order characters also control native vs. standard type sizes
          if stream.byteorder in ("@", "^"):
              type_map = _pep3118_native_map
              type_map_chars = _pep3118_native_typechars
          else:
              type_map = _pep3118_standard_map
              type_map_chars = _pep3118_standard_typechars
  
          # Item sizes
          itemsize_str = stream.consume_until(lambda c: not c.isdigit())
          if itemsize_str:
              itemsize = int(itemsize_str)
          else:
              itemsize = 1
  
          # Data types
          is_padding = False
  
          if stream.consume("T{"):
              value, align = __dtype_from_pep3118(
                  stream, is_subdtype=True
              )
          elif stream.next in type_map_chars:
              if stream.next == "Z":
                  typechar = stream.advance(2)
              else:
                  typechar = stream.advance(1)
  
              is_padding = typechar == "x"
              dtypechar = type_map[typechar]
              if dtypechar in "USV":
                  dtypechar += "%d" % itemsize
                  itemsize = 1
              numpy_byteorder = {"@": "=", "^": "="}.get(
                  stream.byteorder, stream.byteorder
              )
              value = dtype(numpy_byteorder + dtypechar)
              align = value.alignment
          elif stream.next in _pep3118_unsupported_map:
              desc = _pep3118_unsupported_map[stream.next]
              raise NotImplementedError(
                  "Unrepresentable PEP 3118 data type {!r} ({})".format(
                      stream.next, desc
                  )
              )
          else:
              raise ValueError(
                  "Unknown PEP 3118 data type specifier %r" % stream.s
              )
  
          #
          # Native alignment may require padding
          #
          # Here we assume that the presence of a '@' character implicitly implies
          # that the start of the array is *already* aligned.
          #
          extra_offset = 0
          if stream.byteorder == "@":
              start_padding = (-offset) % align
              intra_padding = (-value.itemsize) % align
  
              offset += start_padding
  
              if intra_padding != 0:
                  if itemsize > 1 or (
                      shape is not None and _prod(shape) > 1
                  ):
                      # Inject internal padding to the end of the sub-item
                      value = _add_trailing_padding(
                          value, intra_padding
                      )
                  else:
                      # We can postpone the injection of internal padding,
                      # as the item appears at most once
                      extra_offset += intra_padding
  
              # Update common alignment
              common_alignment = _lcm(align, common_alignment)
  
          # Convert itemsize to sub-array
          if itemsize != 1:
              value = dtype((value, (itemsize,)))
  
          # Sub-arrays (2)
          if shape is not None:
              value = dtype((value, shape))
  
          # Field name
          if stream.consume(":"):
              name = stream.consume_until(":")
          else:
              name = None
  
          if not (is_padding and name is None):
              if name is not None and name in field_spec["names"]:
                  raise RuntimeError(
                      "Duplicate field name '%s' in PEP3118 format"
                      % name
                  )
              field_spec["names"].append(name)
              field_spec["formats"].append(value)
              field_spec["offsets"].append(offset)
  
          offset += value.itemsize
          offset += extra_offset
  
          field_spec["itemsize"] = offset
  
      # extra final padding for aligned types
      if stream.byteorder == "@":
          field_spec["itemsize"] += (-offset) % common_alignment
  
      # Check if this was a simple 1-item type, and unwrap it
      if (
          field_spec["names"] == [None]
          and field_spec["offsets"][0] == 0
          and field_spec["itemsize"]
          == field_spec["formats"][0].itemsize
          and not is_subdtype
      ):
          ret = field_spec["formats"][0]
      else:
          _fix_names(field_spec)
          ret = dtype(field_spec)
  
      # Finished
      return ret, common_alignment
  
imports: from __future__ import division, absolute_import, print_function
  import re
  import sys
  import platform
  from numpy.compat import unicode
  from numpy.core.overrides import set_module
  from .multiarray import dtype, array, ndarray
label_desc: Use image node_id 12 for calling a global function with example usage: __dtype_from_pep3118(stream, is_subdtype) and returns: ret,  common_alignment