code: def populate_tabs(self):
          
          self.delete_tabs()
          layer_purpose = self.metadata.get('layer_purpose')
          if not layer_purpose:
              message = tr(
                  'Key layer_purpose is not found in the layer {layer_name}'
              ).format(layer_name=self.layer.name())
              raise KeywordNotFoundError(message)
          if layer_purpose == layer_purpose_exposure['key']:
              layer_subcategory = self.metadata.get('exposure')
          elif layer_purpose == layer_purpose_hazard['key']:
              layer_subcategory = self.metadata.get('hazard')
          else:
              layer_subcategory = None
  
          field_groups = get_field_groups(layer_purpose, layer_subcategory)
          for field_group in field_groups:
              tab = FieldMappingTab(field_group, self, self.iface)
              tab.set_layer(self.layer, self.metadata)
              self.addTab(tab, field_group['name'])
              self.tabs.append(tab)
docs: Populating tabs based on layer metadata.