def _transform_sample(
        self,
        sample,
        expand_schema=True,
        dynamic=False,
        validate=True,
        copy=False,
        include_id=False,
    ):
        """Transforms the given sample and returns the transformed sample and
        dict as a pair.

        This method handles schema expansion, validation, and preparing the
        sample's backing document before adding it to the database.

        Args:
            sample: the sample to transform
            expand_schema (True): whether to dynamically add new sample fields
                encountered
            dynamic (False: whether to declare dynamic attributes of embedded
                document fields
            validate (True): whether to validate the sample against the dataset
                schema
            copy (False): whether to create a copy of the sample if it's
                already in a dataset
            include_id (False): whether to include the sample's ID in the
                backing document

        Returns:
            a tuple of

            -   ``transformed_sample``
            -   ``backing_document_dict``
        """
        if copy and sample._in_db:
            sample = sample.copy()

        if self.media_type is None and sample:
            self.media_type = _get_media_type(sample)

        if expand_schema:
            self._expand_schema(sample, dynamic)

        if validate:
            self._validate_sample(sample)

        now = datetime.utcnow()

        return (
            sample,
            self._make_dict(
                sample,
                include_id=include_id,
                created_at=now,
                last_modified_at=now,
            ),
        )
Transforms the given sample and returns the transformed sample and
        dict as a pair.

        This method handles schema expansion, validation, and preparing the
        sample's backing document before adding it to the database.

        Args:
            sample: the sample to transform
            expand_schema (True): whether to dynamically add new sample fields
                encountered
            dynamic (False: whether to declare dynamic attributes of embedded
                document fields
            validate (True): whether to validate the sample against the dataset
                schema
            copy (False): whether to create a copy of the sample if it's
                already in a dataset
            include_id (False): whether to include the sample's ID in the
                backing document

        Returns:
            a tuple of

            -   ``transformed_sample``
            -   ``backing_document_dict``
        
fiftyone/core/dataset.py