code: def get_field_groups(layer_purpose, layer_subcategory=None):
      
      layer_purpose_dict = definition(layer_purpose)
      if not layer_purpose_dict:
          return []
      field_groups = deepcopy(layer_purpose_dict.get('field_groups', []))
      if layer_purpose in [
              layer_purpose_exposure['key'], layer_purpose_hazard['key']]:
          if layer_subcategory:
              subcategory = definition(layer_subcategory)
              if 'field_groups' in subcategory:
                  field_groups += deepcopy(subcategory['field_groups'])
      return field_groups
docs: Obtain list of field groups from layer purpose and subcategory.
  
      :param layer_purpose: The layer purpose.
      :type layer_purpose: str
  
      :param layer_subcategory: Exposure or hazard value.
      :type layer_subcategory: str
  
      :returns: List of layer groups.
      :rtype: list