code: def _hparam_constructible_class(ty):
      """
      Given a type, returns:
      - an unambiguous HParam subtype, if one exists,
      - None, if there are no HParam subtypes
      If there is ambiguity, throws a TypeError.
      """
      subtypes = _union_subtypes(ty)
  
      hparam_subtypes = [ty for ty in subtypes if is_hparam_type(ty)]
  
      if len(hparam_subtypes) > 1:
          raise TypeError(
              f"Unions with multiple HParam subtypes unsupported"
          )
      if len(hparam_subtypes) == 0:
          return None
      assert len(hparam_subtypes) == 1
      hparam_ty = hparam_subtypes[0]
      if dict in subtypes:
          # avoid ambiguity for nested dict construction
          raise TypeError(
              f"Unions with both HParam and dict subtypes unsupported"
          )
      if str in subtypes:
          # avoid ambiguity for "on"/"off"
          raise TypeError(
              f"Unions with both HParam and str subtypes unsupported"
          )
      return hparam_ty
  
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 9 for calling a global function with example usage: _hparam_constructible_class(ty) and returns: hparam_ty, None