    def try_get_stride_strs(
        self, dim: int, dim_names: List[str] = None
    ) -> Optional[List[str]]:
        """
        Tries to return a list of stride strs for the given dim.
        Note that both dim and dim_names are based on self.original_shapes.

        Returns None if this function fails to calculate stride strs.
        """

        assert dim < len(self.original_shapes), (
            f"dim {dim} must be smaller than original_shapes' rank, "
            f"{len(self.original_shapes)}"
        )
        if dim_names is not None:
            assert len(dim_names) == len(self.original_shapes), (
                "dim_names must have the same length as shapes, "
                f"dim_names: {dim_names}, shapes: {self.original_shapes}"
            )

        def _get_value_or_names(
            shape: List[IntVar], indices: Iterable[int]
        ) -> List[str]:
            res = []
            for index in indices:
                d = shape[index]
                if isinstance(d, IntImm):
                    res.append(str(d.value()))
                else:
                    res.append(
                        dim_names[index] if dim_names is not None else d._attrs["name"]
                    )
            return res

        if self.stride_dim is None:
            # There are no stride dims. Use original shapes to calculate directly.
            return _get_value_or_names(
                self.original_shapes, range(dim + 1, len(self.original_shapes))
            )

        if self._dim_mapping is None:
            # self._dim_mapping cannot be generated successfully.
            # Return None to represent an error.
            _LOGGER.debug("Failed to get dim mapping.")
            return None

        # Loop through self._dim_mapping to generate stride_strs.
        found_original_dim_group = False
        res = []
        for original_group, actual_group in self._dim_mapping:
            if not found_original_dim_group:
                if dim in original_group:
                    found_original_dim_group = True
                    idx = original_group.index(dim)
                    if (self.stride_dim in actual_group) and (
                        idx != len(original_group) - 1
                    ):
                        # If self.stride_dim is in the corresponding group,
                        # need to make sure that dim is the last dim
                        # inside the original group.
                        # Otherwise, we cannot compute strides.
                        _LOGGER.debug(
                            "Multiple dims in stride_dim group. "
                            f"dim_mapping: {self._dim_mapping}, "
                            f"dim: {dim}, stride_dim: {self.stride_dim}, self: {self}"
                        )
                        return None
                    res.extend(
                        _get_value_or_names(
                            self.original_shapes, original_group[idx + 1 :]
                        )
                    )
            else:
                if self.stride_dim in actual_group:
                    if actual_group.index(self.stride_dim) != 0:
                        _LOGGER.debug(
                            f"Stride dim {self.stride_dim} is not the first dim "
                            f"of the underlying group {actual_group}."
                        )
                        return None
                    res.extend(_get_value_or_names(self.actual_shapes, actual_group))
                else:
                    res.extend(
                        _get_value_or_names(self.original_shapes, original_group)
                    )

        _LOGGER.debug(
            f"dim: {dim}, stride_dim: {self.stride_dim}, "
            f"mapping: {self._dim_mapping}, stride_strs: {res}, "
            f"original: {self.original_shapes}, actual: {self.actual_shapes}"
        )
        return res
Tries to return a list of stride strs for the given dim.
Note that both dim and dim_names are based on self.original_shapes.

Returns None if this function fails to calculate stride strs.
python/aitemplate/compiler/tensor_accessor.py