def switch(self, mapping, default=None):
        """Applies a switch statement to this expression, which effectively
        computes the given pseudocode::

            for key, value in mapping.items():
                if self.apply(key):
                    return value

            if default is not None:
                return default

        Examples::

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

            dataset = foz.load_zoo_dataset("quickstart")

            # Round `uniqueness` values to either 0.25 or 0.75
            view = dataset.set_field(
                "uniqueness",
                F("uniqueness").switch(
                    {
                        (0.0 < F()) & (F() <= 0.5): 0.25,
                        (0.5 < F()) & (F() <= 1.0): 0.75,
                    },
                )
            )

            print(view.count_values("uniqueness"))

        Args:
            mapping: a dict mapping boolean :class:`ViewExpression` keys to
                literal or :class:`ViewExpression` values
            default (None): an optional literal or :class:`ViewExpression` to
                return if none of the switch branches are taken

        Returns:
            a :class:`ViewExpression`
        """
        branches = []
        for key, value in mapping.items():
            key._freeze_prefix("$$expr")
            branches.append({"case": key, "then": value})

        switch = {"branches": branches}
        if default is not None:
            switch["default"] = default

        return ViewExpression(
            {"$let": {"vars": {"expr": self}, "in": {"$switch": switch}}}
        )
Applies a switch statement to this expression, which effectively
        computes the given pseudocode::

            for key, value in mapping.items():
                if self.apply(key):
                    return value

            if default is not None:
                return default

        Examples::

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

            dataset = foz.load_zoo_dataset("quickstart")

            # Round `uniqueness` values to either 0.25 or 0.75
            view = dataset.set_field(
                "uniqueness",
                F("uniqueness").switch(
                    {
                        (0.0 < F()) & (F() <= 0.5): 0.25,
                        (0.5 < F()) & (F() <= 1.0): 0.75,
                    },
                )
            )

            print(view.count_values("uniqueness"))

        Args:
            mapping: a dict mapping boolean :class:`ViewExpression` keys to
                literal or :class:`ViewExpression` values
            default (None): an optional literal or :class:`ViewExpression` to
                return if none of the switch branches are taken

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