code: def singleton(class_):
      
      instances = {}
  
      def get_instance(*args, **kwargs):
          if class_ not in instances:
              instances[class_] = class_(*args, **kwargs)
          return instances[class_]
      return get_instance
docs: Singleton definition.
  
      Method 1 from
      https://stackoverflow.com/questions/6760685/creating-a-singleton-in-python