<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _neigh_template(parameters, index, left=True, required=False, notfoundmsg=None):
 """ Generate neighbour matching call for HTMLElement, which returns only elements with required neighbours. Args: parameters (list):
 List of parameters for ``.match()``. index (int):
 Index of the item you want to get from ``.match()`` call. left (bool, default True):
 Look for neigbour in the left side of el. required (bool, default False):
 Use :func:`_required_idiom` to returned data. notfoundmsg (str, default None):
 Message which will be used for :func:`_required_idiom` if the item is not found. Returns: str: Python code. """

    fn_string = "has_neigh(%s, left=%s)" % (
        repr(parameters.fn_params)[1:-1],
        repr(left)
    )

    output = IND + "el = dom.find(\n"
    output += IND + IND + "%s,\n" % repr(parameters.tag_name)

    if parameters.params:
        output += IND + IND + "%s,\n" % repr(parameters.params)

    output += IND + IND + "fn=%s\n" % fn_string
    output += IND + ")\n\n"

    if required:
        return output + _required_idiom(
            parameters.fn_params[0],
            index,
            notfoundmsg
        )

    return output + _index_idiom("el", index)