<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _extract_variables(param):
 """Find all template variables in args."""


    variables = set()

    if isinstance(param, list):
        variables.update(*[_extract_variables(x) for x in param])
    elif isinstance(param, dict):
        variables.update(*[_extract_variables(x) for x in param.values()])
    elif isinstance(param, str):
        for match in re.finditer(TEMPLATE_REGEX, param):
            if match.group('short_id') is not None:
                variables.add(match.group('short_id'))
            else:
                variables.add(match.group('long_id'))

    return variables