code: def to_writeable(source):
      """Convert input object ``source`` to something we can write
  
      Parameters
      ----------
      source : object
  
      Returns
      -------
      arr : None or ndarray or EmptyStructMarker
          If `source` cannot be converted to something we can write to a matfile,
          return None.  If `source` is equivalent to an empty dictionary, return
          ``EmptyStructMarker``.  Otherwise return `source` converted to an
          ndarray with contents for writing to matfile.
      """
      if isinstance(source, np.ndarray):
          return source
      if source is None:
          return None
      # Objects that implement mappings
      is_mapping = (
          hasattr(source, "keys")
          and hasattr(source, "values")
          and hasattr(source, "items")
      )
      # Objects that don't implement mappings, but do have dicts
      if isinstance(source, np.generic):
          # Numpy scalars are never mappings (pypy issue workaround)
          pass
      elif not is_mapping and hasattr(source, "__dict__"):
          source = dict(
              (key, value)
              for key, value in source.__dict__.items()
              if not key.startswith("_")
          )
          is_mapping = True
      if is_mapping:
          dtype = []
          values = []
          for field, value in source.items():
              if (
                  isinstance(field, string_types)
                  and field[0] not in "_0123456789"
              ):
                  dtype.append((str(field), object))
                  values.append(value)
          if dtype:
              return np.array([tuple(values)], dtype)
          else:
              return EmptyStructMarker
      # Next try and convert to an array
      narr = np.asanyarray(source)
      if (
          narr.dtype.type in (object, np.object_)
          and narr.shape == ()
          and narr == source
      ):
          # No interesting conversion possible
          return None
      return narr
  
imports: from __future__ import division, print_function, absolute_import
  import os
  import time
  import sys
  import zlib
  from io import BytesIO
  import warnings
  import numpy
  from numpy.compat import asbytes, asstr
  import scipy.sparse
  from scipy._lib.six import string_types
  from .byteordercodes import native_code, swapped_code
  from .miobase import MatFileReader, docfiller, matdims, read_dtype, arr_to_chars, arr_dtype_number, MatWriteError, MatReadError, MatReadWarning
  from .mio5_utils import VarReader5
  from .mio5_params import MatlabObject, MatlabFunction, MDTYPES, NP_TO_MTYPES, NP_TO_MXTYPES, miCOMPRESSED, miMATRIX, miINT8, miUTF8, miUINT32, mxCELL_CLASS, mxSTRUCT_CLASS, mxOBJECT_CLASS, mxCHAR_CLASS, mxSPARSE_CLASS, mxDOUBLE_CLASS, mclass_info
  from .streams import ZlibInputStream
label_desc: Use image node_id 2 for calling a global function with example usage: to_writeable(source) and returns: narr, source, None, None, np, EmptyStructMarker