def let_in(self, expr):
        """Returns an equivalent expression where this expression is defined as
        a variable that is used wherever necessary in the given expression.

        This method is useful when ``expr`` contains multiple instances of this
        expression, since it avoids duplicate computation of this expression in
        the final pipeline.

        If ``expr`` is a simple expression such as a :class:`ViewField`, no
        variable is defined and ``expr`` is directly returned.

        Examples::

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

            dataset = foz.load_zoo_dataset("quickstart")

            # Bboxes are in [top-left-x, top-left-y, width, height] format
            bbox_area = F("bounding_box")[2] * F("bounding_box")[3]

            good_bboxes = (bbox_area > 0.25) & (bbox_area < 0.75)

            # Optimize the expression
            good_bboxes_opt = bbox_area.let_in(good_bboxes)

            # Contains predictions whose bounding box areas are in [0.25, 0.75]
            view = dataset.filter_labels("predictions", good_bboxes_opt)

            print(good_bboxes)
            print(good_bboxes_opt)
            print(dataset.count("predictions.detections"))
            print(view.count("predictions.detections"))

        Args:
            expr: a :class:`ViewExpression`

        Returns:
            a :class:`ViewExpression`
        """
        if isinstance(self, (ViewField, ObjectId)):
            return expr

        return self._let_in(expr)
Returns an equivalent expression where this expression is defined as
        a variable that is used wherever necessary in the given expression.

        This method is useful when ``expr`` contains multiple instances of this
        expression, since it avoids duplicate computation of this expression in
        the final pipeline.

        If ``expr`` is a simple expression such as a :class:`ViewField`, no
        variable is defined and ``expr`` is directly returned.

        Examples::

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

            dataset = foz.load_zoo_dataset("quickstart")

            # Bboxes are in [top-left-x, top-left-y, width, height] format
            bbox_area = F("bounding_box")[2] * F("bounding_box")[3]

            good_bboxes = (bbox_area > 0.25) & (bbox_area < 0.75)

            # Optimize the expression
            good_bboxes_opt = bbox_area.let_in(good_bboxes)

            # Contains predictions whose bounding box areas are in [0.25, 0.75]
            view = dataset.filter_labels("predictions", good_bboxes_opt)

            print(good_bboxes)
            print(good_bboxes_opt)
            print(dataset.count("predictions.detections"))
            print(view.count("predictions.detections"))

        Args:
            expr: a :class:`ViewExpression`

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