code: def _matstruct_to_dict(matobj):
      """Construct nested dicts from mat_struct objects."""
      d = {}
      for f in matobj._fieldnames:
          elem = matobj.__dict__[f]
          if isinstance(elem, mat_struct):
              d[f] = _matstruct_to_dict(elem)
          elif _has_struct(elem):
              d[f] = _inspect_cell_array(elem)
          else:
              d[f] = elem
      return d
  
imports: import os
  import time
  import sys
  import zlib
  from io import BytesIO
  import warnings
  import numpy
  import scipy.sparse
  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, mat_struct
  from .streams import ZlibInputStream
label_desc: Use image node_id 3 for calling a global function with example usage: _matstruct_to_dict(matobj) and returns: d