def multi_mode_write(buffer_writer, string_writer, buffer_or_path=None):
    """
    Get a StringIO from different type of inputs.

    Parameters
    ----------
    buffer_writer
    string_writer
    buffer_or_path

    Returns
    -------
    typing.StringIO
    """
    if buffer_or_path is None:
        return string_writer()
    if isinstance(buffer_or_path, str):
        buffer = open(buffer_or_path, 'w')
    else:
        buffer = buffer_or_path
    with buffer:
        buffer_writer(buffer)
