def __getitem__(self, idx_or_slice):
        """Returns the element or slice of this expression, which must resolve
        to an array.

        All of the typical slicing operations are supported, except for
        specifying a non-unit step::

            expr[3]      # the fourth element
            expr[-1]     # the last element
            expr[:10]    # the first (up to) 10 elements
            expr[-3:]    # the last (up to) 3 elements
            expr[3:10]   # the fourth through tenth elements

        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]

            # Only contains objects in the `predictions` field with area > 0.2
            view = dataset.filter_labels("predictions", bbox_area > 0.2)

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

        Args:
            idx_or_slice: the index or slice

        Returns:
            a :class:`ViewExpression`
        """
        if not isinstance(idx_or_slice, slice):
            return ViewExpression({"$arrayElemAt": [self, idx_or_slice]})

        s = idx_or_slice

        if s.step is not None and s.step != 1:
            raise ValueError(
                "Unsupported slice '%s'; step is not supported" % s
            )

        # @todo could optimize this slightly (~10% based on rough benchmarks)
        # if the `if_else()` calls were replaced by explicit logic when
        # start/stop are numbers, not expressions

        # @todo slices like `x[-a:b]` where sign(a) != sign(b) are not
        # currently working

        if s.start is not None:
            position = s.start
            if s.stop is None:
                n = self.length()
                expr = ViewExpression({"$slice": [self, position, n]})
                return self.let_in(expr)

            n = s.stop - position

            pos_start = ViewExpression({"$slice": [self, position, n]})
            neg_start = ViewExpression(
                {"$slice": [self, position + self.length(), n]}
            )
            expr = ViewExpression(n >= 0).if_else(
                ViewExpression(position >= 0).if_else(pos_start, neg_start),
                ViewExpression({"$literal": []}),
            )
            return self.let_in(expr)

        if s.stop is None:
            return self

        pos_stop = ViewExpression({"$slice": [self, s.stop]})
        neg_stop = ViewExpression({"$slice": [self, self.length() + s.stop]})
        expr = ViewExpression(s.stop >= 0).if_else(pos_stop, neg_stop)
        return self.let_in(expr)
Returns the element or slice of this expression, which must resolve
        to an array.

        All of the typical slicing operations are supported, except for
        specifying a non-unit step::

            expr[3]      # the fourth element
            expr[-1]     # the last element
            expr[:10]    # the first (up to) 10 elements
            expr[-3:]    # the last (up to) 3 elements
            expr[3:10]   # the fourth through tenth elements

        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]

            # Only contains objects in the `predictions` field with area > 0.2
            view = dataset.filter_labels("predictions", bbox_area > 0.2)

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

        Args:
            idx_or_slice: the index or slice

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