class_docstr: Implement a manager class to add the new component properly.
  The component can be added as either class or function type.
  
  Args:
      name (str): The name of component.
  
  Returns:
      A callable object of ComponentManager.
  
  Examples 1:
  
      from paddleseg.cvlibs.manager import ComponentManager
  
      model_manager = ComponentManager()
  
      class AlexNet: ...
      class ResNet: ...
  
      model_manager.add_component(AlexNet)
      model_manager.add_component(ResNet)
  
      # Or pass a sequence alliteratively:
      model_manager.add_component([AlexNet, ResNet])
      print(model_manager.components_dict)
      # {'AlexNet': <class '__main__.AlexNet'>, 'ResNet': <class '__main__.ResNet'>}
  
  Examples 2:
  
      # Or an easier way, using it as a Python decorator, while just add it above the class declaration.
      from paddleseg.cvlibs.manager import ComponentManager
  
      model_manager = ComponentManager()
  
      @model_manager.add_component
      class AlexNet: ...
  
      @model_manager.add_component
      class ResNet: ...
  
      print(model_manager.components_dict)
      # {'AlexNet': <class '__main__.AlexNet'>, 'ResNet': <class '__main__.ResNet'>}
class_docstr_tok: ["Implement","a","manager","class","to","add","the","new","component","properly",".","The","component","can","be","added","as","either","class","or","function","type",".","Args",":","name","(","str",")",":","The","name","of","component",".","Returns",":","A","callable","object","of","ComponentManager",".","Examples","1",":","from","paddleseg.cvlibs.manager","import","ComponentManager","model_manager","=","ComponentManager","(",")","class","AlexNet",":","...","class","ResNet",":","...","model_manager.add_component","(","AlexNet",")","model_manager.add_component","(","ResNet",")","#","Or","pass","a","sequence","alliteratively",":","model_manager.add_component","(","[","AlexNet",",","ResNet","]",")","print","(","model_manager.components_dict",")","#","{","'AlexNet","'",":","<","class","'__main__.AlexNet","'",">",",","'ResNet","'",":","<","class","'__main__.ResNet","'",">","}","Examples","2",":","#","Or","an","easier","way",",","using","it","as","a","Python","decorator",",","while","just","add","it","above","the","class","declaration",".","from","paddleseg.cvlibs.manager","import","ComponentManager","model_manager","=","ComponentManager","(",")","@","model_manager.add_component","class","AlexNet",":","...","@","model_manager.add_component","class","ResNet",":","...","print","(","model_manager.components_dict",")","#","{","'AlexNet","'",":","<","class","'__main__.AlexNet","'",">",",","'ResNet","'",":","<","class","'__main__.ResNet","'",">","}"]
docstr: Add a single component into the corresponding manager.
  
  Args:
      component (function|class): A new component.
  
  Raises:
      TypeError: When `component` is neither class nor function.
      KeyError: When `component` was added already.
docstr_tok: ["Add","a","single","component","into","the","corresponding","manager",".","Args",":","component","(","function|class",")",":","A","new","component",".","Raises",":","TypeError",":","When","`","component","`","is","neither","class","nor","function",".","KeyError",":","When","`","component","`","was","added","already","."]
code: def _add_single_component(self, component):
      """
      Add a single component into the corresponding manager.
  
      Args:
          component (function|class): A new component.
  
      Raises:
          TypeError: When `component` is neither class nor function.
          KeyError: When `component` was added already.
      """
  
      # Currently only support class or function type
      if not (
          inspect.isclass(component) or inspect.isfunction(component)
      ):
          raise TypeError(
              "Expect class/function type, but received {}".format(
                  type(component)
              )
          )
  
      # Obtain the internal name of the component
      component_name = component.__name__
  
      # Check whether the component was added already
      if component_name in self._components_dict.keys():
          warnings.warn(
              "{} exists already! It is now updated to {} !!!".format(
                  component_name, component
              )
          )
          self._components_dict[component_name] = component
  
      else:
          # Take the internal name of the component as its key
          self._components_dict[component_name] = component
  
file_path: PaddleSeg/contrib/MedicalSeg/medicalseg/cvlibs/manager.py
imports: import inspect
  from collections.abc import Sequence
  import warnings
label_desc: Use image node_id 7 for calling the ComponentManager obj's underlying member method code with example usage: obj._add_single_component(component) without return types