code: def mat_reader_factory(file_name, appendmat=True, **kwargs):
      """
      Create reader for matlab .mat format files.
  
      Parameters
      ----------
      %(file_arg)s
      %(append_arg)s
      %(load_args)s
      %(struct_arg)s
  
      Returns
      -------
      matreader : MatFileReader object
         Initialized instance of MatFileReader class matching the mat file
         type detected in `filename`.
      file_opened : bool
         Whether the file was opened by this routine.
  
      """
      byte_stream, file_opened = _open_file(file_name, appendmat)
      mjv, mnv = get_matfile_version(byte_stream)
      if mjv == 0:
          return MatFile4Reader(byte_stream, **kwargs), file_opened
      elif mjv == 1:
          return MatFile5Reader(byte_stream, **kwargs), file_opened
      elif mjv == 2:
          raise NotImplementedError(
              "Please use HDF reader for matlab v7.3 files"
          )
      else:
          raise TypeError("Did not recognize version %s" % mjv)
  
file_path: catboost/contrib/python/scipy/py3/scipy/io/matlab/mio.py
imports: from contextlib import contextmanager
  from .miobase import get_matfile_version, docfiller
  from .mio4 import MatFile4Reader, MatFile4Writer
  from .mio5 import MatFile5Reader, MatFile5Writer
label_desc: Use image node_id 3 for calling a global function with example usage: mat_reader_factory(file_name, appendmat) and returns: MatFile4Reader,  file_opened, MatFile5Reader,  file_opened