<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _gather_variables(stack_def):
 """Merges context provided & stack defined variables. If multiple stacks have a variable with the same name, we can specify the value for a specific stack by passing in the variable name as: `<stack name>::<variable name>`. This variable value will only be used for that specific stack. Order of precedence: - context defined stack specific variables (ie. SomeStack::SomeVariable) - context defined non-specific variables - variable defined within the stack definition Args: stack_def (dict):
 The stack definition being worked on. Returns: dict: Contains key/value pairs of the collected variables. Raises: AttributeError: Raised when the stack definitition contains an invalid attribute. Currently only when using old parameters, rather than variables. """

    variable_values = copy.deepcopy(stack_def.variables or {})
    return [Variable(k, v) for k, v in variable_values.items()]