from typing import OrderedDict


def _get_input_and_output_names(intrp):
    """
    Get input and output tensor names

    Parameters
    ----------
    intrp : :py:class:`str`tf.lite.Interpreter`
        TFLite Interpreter

    Returns
    -------
    input_tensor_dict : Input tensor Dict which maps tensor_name to tensor_id
    output_tensor_dict : Output tensor Dict which maps tensor_name to tensor_id
    """
    # Use OrderedDict to keep tensor names order
    input_tensor_dict = OrderedDict()
    output_tensor_dict = OrderedDict()
    for d in intrp.get_input_details():
        input_tensor_dict[d["name"]] = d["index"]
    for d in intrp.get_output_details():
        output_tensor_dict[d["name"]] = d["index"]
    return input_tensor_dict, output_tensor_dict