def set_field(self, field, value_or_expr, relative=True):
        """Sets the specified field or embedded field of this expression, which
        must resolve to a document, to the given value or expression.

        By default, the provided expression is computed by applying it to this
        expression via ``self.apply(value_or_expr)``.

        Examples::

            import fiftyone as fo
            import fiftyone.zoo as foz
            from fiftyone import ViewField as F

            dataset = foz.load_zoo_dataset("quickstart")

            #
            # Replaces the `label` attributes of the objects in the
            # `predictions` field according to the following rule:
            #
            #   If the `label` starts with `b`, replace it with `b`. Otherwise,
            #   replace it with "other"
            #
            view = dataset.set_field(
                "predictions.detections",
                F("detections").map(
                    F().set_field(
                        "label",
                        F("label").re_match("^b").if_else("b", "other"),
                    )
                )
            )

            print(view.count_values("predictions.detections.label"))

        Args:
            field: the "field" or "embedded.field.name" to set
            value_or_expr: a literal value or :class:`ViewExpression` defining
                the field to set
            relative (True): whether to compute ``value_or_expr`` by applying
                it to this expression (True), or to use it untouched (False)

        Returns:
            a :class:`ViewExpression`
        """
        if (
            isinstance(value_or_expr, ViewExpression)
            and relative
            and not value_or_expr.is_frozen
        ):
            value = self.apply(value_or_expr)
        elif isinstance(value_or_expr, MongoEngineBaseDocument):
            value = value_or_expr.to_dict()
            value.pop("_id", None)
        else:
            value = value_or_expr

        field = "$$expr." + field
        expr = value
        chunks = field.split(".")
        for idx, chunk in enumerate(reversed(chunks[1:]), 1):
            expr = {"$mergeObjects": [".".join(chunks[:-idx]), {chunk: expr}]}

        return self._let_in(ViewExpression(expr), var="expr")
Sets the specified field or embedded field of this expression, which
        must resolve to a document, to the given value or expression.

        By default, the provided expression is computed by applying it to this
        expression via ``self.apply(value_or_expr)``.

        Examples::

            import fiftyone as fo
            import fiftyone.zoo as foz
            from fiftyone import ViewField as F

            dataset = foz.load_zoo_dataset("quickstart")

            #
            # Replaces the `label` attributes of the objects in the
            # `predictions` field according to the following rule:
            #
            #   If the `label` starts with `b`, replace it with `b`. Otherwise,
            #   replace it with "other"
            #
            view = dataset.set_field(
                "predictions.detections",
                F("detections").map(
                    F().set_field(
                        "label",
                        F("label").re_match("^b").if_else("b", "other"),
                    )
                )
            )

            print(view.count_values("predictions.detections.label"))

        Args:
            field: the "field" or "embedded.field.name" to set
            value_or_expr: a literal value or :class:`ViewExpression` defining
                the field to set
            relative (True): whether to compute ``value_or_expr`` by applying
                it to this expression (True), or to use it untouched (False)

        Returns:
            a :class:`ViewExpression`
        
fiftyone/core/expressions.py