code: def parse_dict_to_dataclasses(
      dataclass_types: Tuple[Any, ...],
      args: Union[Dict[str, Any], utils.AttrDict],
      as_dict: bool = False,
  ) -> Tuple[Any, ...]:
      """
      This function will fill in values for a dataclass if the target key is found
      in the provided args dictionary.  We can have one argument key value be filled in
      to multiple dataclasses if the key is found in them.
  
      Args:
          dataclass_types: dataclasses with expected attributes.
          args: arguments that will be parsed to each of the dataclass_types.
          as_dict: if true will return dictionary instead of AttrDict
  
      Returns:
          One dictionary for each dataclass with keys filled in from args if found.
      """
      outputs = []
      for dtype in dataclass_types:
          keys = {f.name for f in dataclasses.fields(dtype) if f.init}
          inputs = {k: v for k, v in args.items() if k in keys}
          obj = dtype(**inputs)
          if as_dict:
              try:
                  obj = utils.AttrDict(obj.as_dict())
              except AttributeError:
                  obj = utils.AttrDict(dataclasses.asdict(obj))
          outputs.append(obj)
      return (*outputs,)
  
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 for calling a global function with example usage: parse_dict_to_dataclasses(dataclass_types, args, as_dict) and returns: unknown