<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_value(instance, path, ref=None):
 """ Get the value from `instance` at the given `path`. Parameters instance : dict or list instance from which to retrieve a value path : str path to retrieve a value from ref : str or None reference path if `path` is relative Returns ------- value : value at `path` in `instance` Raises ------ KeyError if `path` is not valid TypeError if a value along the `path` is not a list or dictionary """

    for part in split_path(path, ref):
        if isinstance(instance, list):
            part = int(part)
        elif not isinstance(instance, dict):
            raise TypeError("expected `list` or `dict` but got `%s`" % instance)
        try:
            instance = instance[part]
        except KeyError:
            raise KeyError(abspath(path, ref))
    return instance