class_docstr: A configurable that only allows one instance.
  
  This class is for classes that should only have one instance of itself
  or *any* subclass. To create and retrieve such a class use the
  :meth:`SingletonConfigurable.instance` method.
class_docstr_tok: ["A","configurable","that","only","allows","one","instance",".","This","class","is","for","classes","that","should","only","have","one","instance","of","itself","or","*","any","*","subclass",".","To","create","and","retrieve","such","a","class","use","the",":","meth",":","`","SingletonConfigurable.instance","`","method","."]
docstr: Returns a global instance of this class.
  
  This method create a new instance if none have previously been created
  and returns a previously created instance is one already exists.
  
  The arguments and keyword arguments passed to this method are passed
  on to the :meth:`__init__` method of the class upon instantiation.
  
  Examples
  --------
  
  Create a singleton class using instance, and retrieve it::
  
      >>> from traitlets.config.configurable import SingletonConfigurable
      >>> class Foo(SingletonConfigurable): pass
      >>> foo = Foo.instance()
      >>> foo == Foo.instance()
      True
  
  Create a subclass that is retrived using the base class instance::
  
      >>> class Bar(SingletonConfigurable): pass
      >>> class Bam(Bar): pass
      >>> bam = Bam.instance()
      >>> bam == Bar.instance()
      True
docstr_tok: ["Returns","a","global","instance","of","this","class",".","This","method","create","a","new","instance","if","none","have","previously","been","created","and","returns","a","previously","created","instance","is","one","already","exists",".","The","arguments","and","keyword","arguments","passed","to","this","method","are","passed","on","to","the",":","meth",":","`","__init__","`","method","of","the","class","upon","instantiation",".","Examples","--","--","--","--","Create","a","singleton","class","using","instance",",","and","retrieve","it",":",":",">",">",">","from","traitlets.config.configurable","import","SingletonConfigurable",">",">",">","class","Foo","(","SingletonConfigurable",")",":","pass",">",">",">","foo","=","Foo.instance","(",")",">",">",">","foo","==","Foo.instance","(",")","True","Create","a","subclass","that","is","retrived","using","the","base","class","instance",":",":",">",">",">","class","Bar","(","SingletonConfigurable",")",":","pass",">",">",">","class","Bam","(","Bar",")",":","pass",">",">",">","bam","=","Bam.instance","(",")",">",">",">","bam","==","Bar.instance","(",")","True"]
code: def instance(cls, *args, **kwargs):
      """Returns a global instance of this class.
  
      This method create a new instance if none have previously been created
      and returns a previously created instance is one already exists.
  
      The arguments and keyword arguments passed to this method are passed
      on to the :meth:`__init__` method of the class upon instantiation.
  
      Examples
      --------
  
      Create a singleton class using instance, and retrieve it::
  
          >>> from traitlets.config.configurable import SingletonConfigurable
          >>> class Foo(SingletonConfigurable): pass
          >>> foo = Foo.instance()
          >>> foo == Foo.instance()
          True
  
      Create a subclass that is retrived using the base class instance::
  
          >>> class Bar(SingletonConfigurable): pass
          >>> class Bam(Bar): pass
          >>> bam = Bam.instance()
          >>> bam == Bar.instance()
          True
      """
      # Create and save the instance
      if cls._instance is None:
          inst = cls(*args, **kwargs)
          # Now make sure that the instance will also be returned by
          # parent classes' _instance attribute.
          for subclass in cls._walk_mro():
              subclass._instance = inst
  
      if isinstance(cls._instance, cls):
          return cls._instance
      else:
          raise MultipleInstanceError(
              "Multiple incompatible subclass instances of "
              "%s are being created." % cls.__name__
          )
  
imports: from __future__ import print_function, absolute_import
  from copy import deepcopy
  import warnings
  from .loader import Config, LazyConfigValue, _is_section_key
  from traitlets.traitlets import HasTraits, Instance, observe, observe_compat, default
  from ipython_genutils.text import indent, dedent, wrap_paragraphs
label_desc: Use image node_id 3 for calling the SingletonConfigurable obj's underlying member method code with example usage: obj.instance(cls) and returns: cls