class_docstr: A subclass to handle dynamic traits
  
  This class is a workaround for add_traits and clone_traits not
  functioning well together.
class_docstr_tok: ["A","subclass","to","handle","dynamic","traits","This","class","is","a","workaround","for","add_traits","and","clone_traits","not","functioning","well","together","."]
docstr: Replace the ``__deepcopy__`` member with a traits-friendly implementation.
  
  A bug in ``__deepcopy__`` for ``HasTraits`` results in weird cloning behaviors.
docstr_tok: ["Replace","the","``","__deepcopy__","``","member","with","a","traits-friendly","implementation",".","A","bug","in","``","__deepcopy__","``","for","``","HasTraits","``","results","in","weird","cloning","behaviors","."]
code: def __deepcopy__(self, memo):
      """
      Replace the ``__deepcopy__`` member with a traits-friendly implementation.
  
      A bug in ``__deepcopy__`` for ``HasTraits`` results in weird cloning behaviors.
      """
      id_self = id(self)
      if id_self in memo:
          return memo[id_self]
      dup_dict = deepcopy(self.trait_get(), memo)
      # access all keys
      for key in self.copyable_trait_names():
          if key in self.__dict__.keys():
              _ = getattr(self, key)
      # clone once
      dup = self.clone_traits(memo=memo)
      for key in self.copyable_trait_names():
          try:
              _ = getattr(dup, key)
          except:
              pass
      # clone twice
      dup = self.clone_traits(memo=memo)
      dup.trait_set(**dup_dict)
      return dup
  
imports: import os
  from inspect import isclass
  from copy import deepcopy
  from warnings import warn
  from packaging.version import Version
  from traits.trait_errors import TraitError
  from traits.trait_handlers import TraitDictObject, TraitListObject
  from ...utils.filemanip import md5, hash_infile, hash_timestamp
  from .traits_extension import traits, File, Str, Undefined, isdefined, has_metadata, OutputMultiObject
  from ...None import config, __version__
label_desc: Use image node_id 1 for calling the DynamicTraitedSpec obj's underlying member method code with example usage: obj.__deepcopy__(memo) and returns: dup, memo