code: def _open_file(file_like, appendmat, mode="rb"):
      """
      Open `file_like` and return as file-like object. First, check if object is
      already file-like; if so, return it as-is. Otherwise, try to pass it
      to open(). If that fails, and `file_like` is a string, and `appendmat` is true,
      append '.mat' and try again.
      """
      reqs = {"read"} if set(mode) & set("r+") else set()
      if set(mode) & set("wax+"):
          reqs.add("write")
      if reqs.issubset(dir(file_like)):
          return file_like, False
  
      try:
          return open(file_like, mode), True
      except IOError as e:
          # Probably "not found"
          if isinstance(file_like, str):
              if appendmat and not file_like.endswith(".mat"):
                  file_like += ".mat"
              return open(file_like, mode), True
          else:
              raise IOError(
                  "Reader needs file name or open file-like object"
              ) from e
  
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 2 for calling a global function with example usage: _open_file(file_like, appendmat, mode) and returns: file_like,  False, open,  True, open,  True