def generate_pydantic_schema_for_metadata(
    metadata_properties: List[Union["AllowedMetadataPropertyTypes", "AllowedRemoteMetadataPropertyTypes"]],
    name: Optional[str] = "MetadataSchema",
    allow_extra_metadata: bool = True,
) -> Type[BaseModel]:
    """Generates a `pydantic.BaseModel` schema from a list of `AllowedMetadataPropertyTypes` or
    `AllowedRemoteMetadataPropertyTypes` objects to validate the metadata of a `FeedbackDataset`
    or `RemoteFeedbackDataset` object, respectively, before inserting them.

    Args:
        metadata_properties: the list of `AllowedMetadataPropertyTypes` or `AllowedRemoteMetadataPropertyTypes`
            objects to generate the schema from.
        name: the name of the `pydantic.BaseModel` schema to generate. Defaults to "MetadataSchema".
        allow_extra_metadata: whether to allow extra metadata properties or not. Defaults to `True`.

    Returns:
        A `pydantic.BaseModel` schema to validate the metadata of a `FeedbackDataset` or `RemoteFeedbackDataset`
        object before inserting them.

    Raises:
        ValueError: if one of the metadata properties has an unsupported type.

    Examples:
        >>> from argilla_v1.client.feedback.schemas.metadata import IntegerMetadataProperty
        >>> from argilla_v1.client.feedback.dataset.helpers import generate_pydantic_schema_for_metadata
        >>> metadata_properties = [
        ...     IntegerMetadataProperty(name="int_metadata", min=0, max=10),
        ...     ...,
        ... ]
        >>> MetadataSchema = generate_pydantic_schema_for_metadata(metadata_properties)
        >>> MetadataSchema(int_metadata=5)
        MetadataSchema(int-metadata=5)
    """
    metadata_fields, metadata_validators = {}, {}

    for metadata_property in metadata_properties or []:
        if metadata_property.type not in [arg.value for arg in MetadataPropertyTypes]:
            raise ValueError(
                f"Metadata property {metadata_property.name} has an unsupported type: {metadata_property.type}, for the moment only the"
                f" following types are supported: {[arg.value for arg in MetadataPropertyTypes]}"
            )
        pydantic_field, pydantic_validator = metadata_property._pydantic_field_with_validator
        metadata_fields.update(pydantic_field)
        metadata_validators.update(pydantic_validator)

    class MetadataConfig:
        extra = Extra.allow if allow_extra_metadata else Extra.forbid

    return create_model(name, **metadata_fields, __validators__=metadata_validators, __config__=MetadataConfig)
Generates a `pydantic.BaseModel` schema from a list of `AllowedMetadataPropertyTypes` or
    `AllowedRemoteMetadataPropertyTypes` objects to validate the metadata of a `FeedbackDataset`
    or `RemoteFeedbackDataset` object, respectively, before inserting them.

    Args:
        metadata_properties: the list of `AllowedMetadataPropertyTypes` or `AllowedRemoteMetadataPropertyTypes`
            objects to generate the schema from.
        name: the name of the `pydantic.BaseModel` schema to generate. Defaults to "MetadataSchema".
        allow_extra_metadata: whether to allow extra metadata properties or not. Defaults to `True`.

    Returns:
        A `pydantic.BaseModel` schema to validate the metadata of a `FeedbackDataset` or `RemoteFeedbackDataset`
        object before inserting them.

    Raises:
        ValueError: if one of the metadata properties has an unsupported type.

    Examples:
        >>> from argilla_v1.client.feedback.schemas.metadata import IntegerMetadataProperty
        >>> from argilla_v1.client.feedback.dataset.helpers import generate_pydantic_schema_for_metadata
        >>> metadata_properties = [
        ...     IntegerMetadataProperty(name="int_metadata", min=0, max=10),
        ...     ...,
        ... ]
        >>> MetadataSchema = generate_pydantic_schema_for_metadata(metadata_properties)
        >>> MetadataSchema(int_metadata=5)
        MetadataSchema(int-metadata=5)
    
argilla-v1/src/argilla_v1/client/feedback/dataset/helpers.py