<｜begin▁of▁sentence｜>### Instruction:
In the realm of probability and computational mathematics, let us consider a practical scenario where we have a set of elements, namely 'apple', 'banana', and 'cherry', each assigned a distinct numerical value corresponding to the element's relative weight—10, 1, and 2, respectively. Imagine that these weights represent the likelihood of selection within a weighted probability distribution.

Can we devise an algorithm akin to a 'weighted_choice' function, which operates upon the aforementioned distribution—encapsulated as a dictionary with elements and their weights—to simulate a random draw? This draw would inherently respect the predefined weighted probabilities, resulting in a random selection that is not equiprobable but rather influenced by the specified weights of the individual items. How might such a function be constructed or utilized to achieve a weighted random selection given such a set of data?
### Response:
import random

# Define a function for making a weighted choice
def weighted_choice(weights):
    choices, weights = zip(*weights.items())
    cum_dist = list(itertools.accumulate(weights))
    x = random.random() * cum_dist[-1]
    for i, total in enumerate(cum_dist):
        if x < total:
            return choices[i]

# Create a dictionary with items and their associated weights
item_weights = {'apple': 10, 'banana': 1, 'cherry': 2}

# Make a weighted choice
selected_item = weighted_choice(item_weights)
print('Selected:', selected_item)
<|EOT|>
