class_docstr: Generic matlab matrix writing class 
docstr: Write `arr` to stream at top and sub levels
  
  Parameters
  ----------
  arr : array_like
      array-like object to create writer for
docstr_tok: ["Write","`","arr","`","to","stream","at","top","and","sub","levels","Parameters","--","--","--","--","--","arr",":","array_like","array-like","object","to","create","writer","for"]
code: def write(self, arr):
      """Write `arr` to stream at top and sub levels
  
      Parameters
      ----------
      arr : array_like
          array-like object to create writer for
      """
      # store position, so we can update the matrix tag
      mat_tag_pos = self.file_stream.tell()
      # First check if these are sparse
      if scipy.sparse.issparse(arr):
          self.write_sparse(arr)
          self.update_matrix_tag(mat_tag_pos)
          return
      # Try to convert things that aren't arrays
      narr = to_writeable(arr)
      if narr is None:
          raise TypeError(
              f"Could not convert {arr} (type {type(arr)}) to array"
          )
      if isinstance(narr, MatlabObject):
          self.write_object(narr)
      elif isinstance(narr, MatlabFunction):
          raise MatWriteError("Cannot write matlab functions")
      elif narr is EmptyStructMarker:  # empty struct array
          self.write_empty_struct()
      elif narr.dtype.fields:  # struct array
          self.write_struct(narr)
      elif narr.dtype.hasobject:  # cell array
          self.write_cells(narr)
      elif narr.dtype.kind in ("U", "S"):
          if self.unicode_strings:
              codec = "UTF8"
          else:
              codec = "ascii"
          self.write_char(narr, codec)
      else:
          self.write_numeric(narr)
      self.update_matrix_tag(mat_tag_pos)
  
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 10 for calling the VarWriter5 obj's underlying member method code with example usage: obj.write(arr) without return types