Amazon Alexa components may store nested state using dictionaries, lists, and sets. Implement deep_clone to create a fully independent copy while preserving the original structure's shared references and supporting cycles.
The function receives one Python value containing only:
None, booleans, integers, floats, strings, and bytes.Return a deep clone with these guarantees:
You may use id(value) to identify object identity. Inputs contain at most 10,000 container objects and a nesting depth of at most 1,000.
def deep_clone(value):