class_docstr: Used as a base class for hyperparameter structs. They also need to be annotated with @dataclass.
class_docstr_tok: ["Used","as","a","base","class","for","hyperparameter","structs",".","They","also","need","to","be","annotated","with","@","dataclass","."]
code: def override_from_json(self, json_val, key=""):
      typemap = _type_map(type(self))
  
      for k, v in json_val.items():
          if k not in typemap:
              raise AttributeError(f"{self} has no attribute {k}")
          t = typemap[k]
          hps_cls = _hparam_constructible_class(t)
          if hps_cls is not None and isinstance(v, dict):
              old_v = getattr(self, k)
              # initialize constructor, overwriting value if it's not the correct class (can happen with Unions)
              if old_v is None or not isinstance(old_v, hps_cls):
                  setattr(self, k, hps_cls())
              getattr(self, k).override_from_json(v, key + "." + k)
          else:
              new_v = _construct_from_json(t, v, key + "." + k)
              check_type(k, new_v, t)
              setattr(self, k, new_v)
  
imports: import typing
  from dataclasses import fields, is_dataclass
  from functools import lru_cache
  from typeguard import check_type
label_desc: Use image node_id 6 for calling the HParams obj's underlying member method code with example usage: obj.override_from_json(json_val, key) without return types