def METHOD_NAME(y):
    if isinstance(y, str):
        v = var_map.get(y, var(y))
        var_map[y] = v
        return v
    elif isinstance(y, dict):
        pattern = y["pattern"]
        if not isinstance(pattern, str):
            raise TypeError(
                "Constraints can only be assigned to logic variables (i.e. strings)"
            )
        constraint = y["constraint"]
        v = var_map.get(pattern, ConstrainedVar(constraint, pattern))
        var_map[pattern] = v
        return v
    elif isinstance(y, tuple):
        return etuple(*tuple(METHOD_NAME(e) for e in y))
    elif isinstance(y, (Number, np.ndarray)):
        from pytensor.tensor import as_tensor_variable
        return as_tensor_variable(y)
    return y