code: def array(
      obj,
      dtype=None,
      shape=None,
      offset=0,
      strides=None,
      formats=None,
      names=None,
      titles=None,
      aligned=False,
      byteorder=None,
      copy=True,
  ):
      """Construct a record array from a wide-variety of objects."""
  
      if (
          (isinstance(obj, (type(None), str)) or isfileobj(obj))
          and (formats is None)
          and (dtype is None)
      ):
          raise ValueError(
              "Must define formats (or dtype) if object is "
              "None, string, or an open file"
          )
  
      kwds = {}
      if dtype is not None:
          dtype = sb.dtype(dtype)
      elif formats is not None:
          dtype = format_parser(
              formats, names, titles, aligned, byteorder
          )._descr
      else:
          kwds = {
              "formats": formats,
              "names": names,
              "titles": titles,
              "aligned": aligned,
              "byteorder": byteorder,
          }
  
      if obj is None:
          if shape is None:
              raise ValueError("Must define a shape if obj is None")
          return recarray(
              shape, dtype, buf=obj, offset=offset, strides=strides
          )
  
      elif isinstance(obj, bytes):
          return fromstring(
              obj, dtype, shape=shape, offset=offset, **kwds
          )
  
      elif isinstance(obj, (list, tuple)):
          if isinstance(obj[0], (tuple, list)):
              return fromrecords(obj, dtype=dtype, shape=shape, **kwds)
          else:
              return fromarrays(obj, dtype=dtype, shape=shape, **kwds)
  
      elif isinstance(obj, recarray):
          if dtype is not None and (obj.dtype != dtype):
              new = obj.view(dtype)
          else:
              new = obj
          if copy:
              new = new.copy()
          return new
  
      elif isfileobj(obj):
          return fromfile(obj, dtype=dtype, shape=shape, offset=offset)
  
      elif isinstance(obj, ndarray):
          if dtype is not None and (obj.dtype != dtype):
              new = obj.view(dtype)
          else:
              new = obj
          if copy:
              new = new.copy()
          return new.view(recarray)
  
      else:
          interface = getattr(obj, "__array_interface__", None)
          if interface is None or not isinstance(interface, dict):
              raise ValueError("Unknown input type")
          obj = sb.array(obj)
          if dtype is not None and (obj.dtype != dtype):
              obj = obj.view(dtype)
          return obj.view(recarray)
  
imports: from __future__ import division, absolute_import, print_function
  import sys
  import os
  import warnings
  from .None import numeric
  from .None import numerictypes
  from numpy.compat import isfileobj, bytes, long, unicode, os_fspath
  from numpy.core.overrides import set_module
  from .arrayprint import get_printoptions
label_desc: Use image node_id 7 for calling a global function with example usage: array(obj, dtype, shape, offset, strides, formats, names, titles, aligned, byteorder, copy) and returns: recarray, fromstring, fromrecords, fromarrays, new, fromfile, new, obj