class_docstr: Helper class to manage the options for variable objects and its configuration.
  
  Example:
  
  >>> class A:
  ...     def __init__(self, foo=3):  pass
  >>> class B:
  ...     def __init__(self, bar="aaaa"):  pass
  >>> choices = ClassChoices("var", dict(a=A, b=B), default="a")
  >>> import argparse
  >>> parser = argparse.ArgumentParser()
  >>> choices.add_arguments(parser)
  >>> args = parser.parse_args(["--var", "a", "--var_conf", "foo=4")
  >>> args.var
  a
  >>> args.var_conf
  {"foo": 4}
  >>> class_obj = choices.get_class(args.var)
  >>> a_object = class_obj(**args.var_conf)
code: def __init__(
      self,
      name: str,
      classes: Mapping[str, type],
      type_check: type = None,
      default: str = None,
      optional: bool = False,
  ):
      assert check_argument_types()
      self.name = name
      self.base_type = type_check
      self.classes = {k.lower(): v for k, v in classes.items()}
      if (
          "none" in self.classes
          or "nil" in self.classes
          or "null" in self.classes
      ):
          raise ValueError('"none", "nil", and "null" are reserved.')
      if type_check is not None:
          for v in self.classes.values():
              if not issubclass(v, type_check):
                  raise ValueError(
                      f"must be {type_check.__name__}, but got {v}"
                  )
  
      self.optional = optional
      self.default = default
      if default is None:
          self.optional = True
  
file_path: espnet/espnet2/train/class_choices.py
imports: from typing import Mapping, Optional, Tuple
  from typeguard import check_argument_types, check_return_type
  from espnet2.utils.nested_dict_action import NestedDictAction
  from espnet2.utils.types import str_or_none
label_desc: Use image node_id 1 to create a new ClassChoices object  with example: obj = ClassChoices(name, classes, type_check, default, optional)