def add_frame(
        self,
        frame_number,
        frame,
        expand_schema=True,
        validate=True,
        dynamic=False,
    ):
        """Adds the frame to this instance.

        If an existing frame with the same frame number exists, it is
        overwritten.

        If the provided frame is a :class:`Frame` instance that does not belong
        to a dataset, it is updated in-place to reflect its membership in this
        dataset. Otherwise, the provided frame is not modified.

        Args:
            frame_number: the frame number
            frame: a :class:`Frame` or :class:`FrameView`
            expand_schema (True): whether to dynamically add new frame fields
                encountered to the dataset schema. If False, an error is raised
                if the frame's schema is not a subset of the dataset schema
            validate (True): whether to validate values for existing fields
            dynamic (False): whether to declare dynamic embedded document
                fields
        """
        fofu.validate_frame_number(frame_number)

        if not isinstance(frame, (Frame, FrameView)):
            raise TypeError(
                "Expected a %s or %s; found %s"
                % (Frame, FrameView, type(frame))
            )

        if self._in_db:
            _frame = frame
            if frame._in_db:
                frame = Frame()

            d = {"_sample_id": self._sample_id}
            doc = self._dataset._frame_dict_to_doc(d)

            for field, value in _frame.iter_fields():
                doc.set_field(
                    field,
                    value,
                    create=expand_schema,
                    validate=validate,
                    dynamic=dynamic,
                    _enforce_read_only=False,
                )

            doc.set_field(
                "frame_number", frame_number, _enforce_read_only=False
            )
            frame._set_backing_doc(doc, dataset=self._dataset)
        else:
            if frame._in_db:
                frame = frame.copy()

            frame.set_field("frame_number", frame_number)

        self._set_replacement(frame)
Adds the frame to this instance.

        If an existing frame with the same frame number exists, it is
        overwritten.

        If the provided frame is a :class:`Frame` instance that does not belong
        to a dataset, it is updated in-place to reflect its membership in this
        dataset. Otherwise, the provided frame is not modified.

        Args:
            frame_number: the frame number
            frame: a :class:`Frame` or :class:`FrameView`
            expand_schema (True): whether to dynamically add new frame fields
                encountered to the dataset schema. If False, an error is raised
                if the frame's schema is not a subset of the dataset schema
            validate (True): whether to validate values for existing fields
            dynamic (False): whether to declare dynamic embedded document
                fields
        
fiftyone/core/frame.py