class_docstr: Create the registry that will map name to object. This facilitates the users to create
      custom registry.
  
      Parameters
      ----------
      name
          The name of the registry
  
      Examples
      --------
  
      >>> from gluonnlp.utils.registry import Registry
      >>> # Create a registry
      >>> MODEL_REGISTRY = Registry('MODEL')
      >>>
      >>> # To register a class/function with decorator
      >>> @MODEL_REGISTRY.register()
  ...     class MyModel:
  ...         pass
      >>> @MODEL_REGISTRY.register()
  ...     def my_model():
  ...         return
      >>>
      >>> # To register a class object with decorator and provide nickname:
      >>> @MODEL_REGISTRY.register('test_class')
  ...     class MyModelWithNickName:
  ...         pass
      >>> @MODEL_REGISTRY.register('test_function')
  ...     def my_model_with_nick_name():
  ...         return
      >>>
      >>> # To register a class/function object by function call
  ...     class MyModel2:
  ...         pass
      >>> MODEL_REGISTRY.register(MyModel2)
      >>> # To register with a given name
      >>> MODEL_REGISTRY.register('my_model2', MyModel2)
      >>> # To list all the registered objects:
      >>> MODEL_REGISTRY.list_keys()
  
  ['MyModel', 'my_model', 'test_class', 'test_function', 'MyModel2', 'my_model2']
  
      >>> # To get the registered object/class
      >>> MODEL_REGISTRY.get('test_class')
  
  __main__.MyModelWithNickName
  
      
class_docstr_tok: ["Create","the","registry","that","will","map","name","to","object",".","This","facilitates","the","users","to","create","custom","registry",".","Parameters","--","--","--","--","--","name","The","name","of","the","registry","Examples","--","--","--","--",">",">",">","from","gluonnlp.utils.registry","import","Registry",">",">",">","#","Create","a","registry",">",">",">","MODEL_REGISTRY","=","Registry","(","'MODEL","'",")",">",">",">",">",">",">","#","To","register","a","class\/function","with","decorator",">",">",">","@","MODEL_REGISTRY.register","(",")","...","class","MyModel",":","...","pass",">",">",">","@","MODEL_REGISTRY.register","(",")","...","def","my_model","(",")",":","...","return",">",">",">",">",">",">","#","To","register","a","class","object","with","decorator","and","provide","nickname",":",">",">",">","@","MODEL_REGISTRY.register","(","'test_class","'",")","...","class","MyModelWithNickName",":","...","pass",">",">",">","@","MODEL_REGISTRY.register","(","'test_function","'",")","...","def","my_model_with_nick_name","(",")",":","...","return",">",">",">",">",">",">","#","To","register","a","class\/function","object","by","function","call","...","class","MyModel2",":","...","pass",">",">",">","MODEL_REGISTRY.register","(","MyModel2",")",">",">",">","#","To","register","with","a","given","name",">",">",">","MODEL_REGISTRY.register","(","'my_model2","'",",","MyModel2",")",">",">",">","#","To","list","all","the","registered","objects",":",">",">",">","MODEL_REGISTRY.list_keys","(",")","[","'MyModel","'",",","'my_model","'",",","'test_class","'",",","'test_function","'",",","'MyModel2","'",",","'my_model2","'","]",">",">",">","#","To","get","the","registered","object\/class",">",">",">","MODEL_REGISTRY.get","(","'test_class","'",")","__main__.MyModelWithNickName"]
docstr: Parameters
  ----------
  name
  json_str
  
  Returns
  -------
docstr_tok: ["Parameters","--","--","--","--","--","name","json_str","Returns","--","--","--","-"]
code: def create_with_json(self, name: str, json_str: str):
      """
  
      Parameters
      ----------
      name
      json_str
  
      Returns
      -------
  
      """
      try:
          args = json.loads(json_str)
      except JSONDecodeError:
          raise ValueError(
              'Unable to decode the json string: json_str="{}"'.format(
                  json_str
              )
          )
      if isinstance(args, (list, tuple)):
          return self.create(name, *args)
      elif isinstance(args, dict):
          return self.create(name, **args)
      else:
          raise NotImplementedError(
              "The format of json string is not supported! We only support "
              'list/dict. json_str="{}".'.format(json_str)
          )
  
file_path: gluon-nlp/src/gluonnlp/utils/registry.py
imports: from typing import Optional, List
  import json
  from json import JSONDecodeError
label_desc: Use image node_id 8 for calling the Registry obj's underlying member method code with example usage: obj.create_with_json(name, json_str) and returns: self, self