class_docstr: A variant of dataclass that allows fields without defaults to be unpopulated for
  class instances.
  
  Fields with defaults will always be set as instance attributes.
  Fields without defaults will be set as attributes only if a value is provided in the init.
class_docstr_tok: ["A","variant","of","dataclass","that","allows","fields","without","defaults","to","be","unpopulated","for","class","instances",".","Fields","with","defaults","will","always","be","set","as","instance","attributes",".","Fields","without","defaults","will","be","set","as","attributes","only","if","a","value","is","provided","in","the","init","."]
code: def __init__(self, **kwargs: Dict[str, Any]) -> None:
      field_names = [f.name for f in dataclasses.fields(self)]
  
      # If a dictionary key corresponds to a field, set it as an attribute.
      for k, v in kwargs.items():
          if k in field_names:
              setattr(self, k, v)
  
      # Otherwise, for fields with defaults, set those attributes.
      for f in dataclasses.fields(self):
          if (
              not hasattr(self, f.name)
              and f.default is not dataclasses.MISSING
          ):
              setattr(self, f.name, f.default)
  
file_path: determined/model_hub/model_hub/huggingface/_config_parser.py
imports: import dataclasses
  from typing import Any, Dict, Optional, Tuple, Union
  from model_hub import utils
label_desc: Use image node_id 1 to create a new FlexibleDataclass object  with example: obj = FlexibleDataclass()