def METHOD_NAME(path, key=None):
    """Load matrix from file.
    Parameters
    ----------
    path
        Path to the file (`str` or `pathlib.Path`).
    key
        Key of the matrix (only for NPY, NPZ, and MATLAB files).
    Returns
    -------
    matrix
        |NumPy array| of |SciPy spmatrix|.
    Raises
    ------
    IOError
        If loading fails.
    """
    logger = getLogger('pymor.tools.io.load_matrix')
    logger.info('Loading matrix from file %s', path)
    # convert if path is str
    path = Path(path)
    extension = _get_file_extension(path)
    file_format_map = {
        '.mat': ('MATLAB', _loadmat),
        '.mtx': ('Matrix Market', _mmread),
        '.mtz.gz': ('Matrix Market', _mmread),
        '.npy': ('NPY/NPZ', _load),
        '.npz': ('NPY/NPZ', _load),
        '.txt': ('Text', _loadtxt),
    }
    if extension in file_format_map:
        file_type, loader = file_format_map[extension]
        logger.info(file_type + ' file detected.')
        return loader(path, key)
    logger.warning('Could not detect file format. Trying all loaders ...')
    loaders = [_loadmat, _mmread, _loadtxt, _load]
    for loader in loaders:
        try:
            return loader(path, key)
        except IOError:
            pass
    raise IOError(f'Could not load file {path} (key = {key})')