def _infer_modality(self, tensor_field: TensorField) -> Modality:
        """Infer the modality of a tensor field. This is used for both unstructured and semi-structured indexes.

        We only infer the field type if the index is configured to treat URLs and pointers as images or media.

        treatUrlsAndPointersAsMedia is a new parameter introduced in Marqo 2.12 to support the new modalities
        of video and audio. Here is how it interacts with treatUrlsAndPointersAsImages:
        - Both False: All content is processed as text only
        - treatUrlsAndPointersAsImages True, treatUrlsAndPointersAsMedia False: Processes URLs and pointers as images.
        Other media types (video, audio) are treated as text
        - treatUrlsAndPointersAsImages False, treatUrlsAndPointersAsMedia True: Invalid state since this is a conflict
        - Both True: Processes URLs and pointers as various media types (images, videos, audio)

        The values of treatUrlsAndPointersAsMedia and treatUrlsAndPointersAsImages are validated in the MarqoIndex
        class, so we do not need to validate them here.

        Args:
            tensor_field: The tensor field to infer the modality.
        Returns:
            The inferred modality
        Raises:
            AddDocumentsError: If the modality of the media content cannot be inferred.
        """
        if (not self.marqo_index.treat_urls_and_pointers_as_images and
                not self.marqo_index.treat_urls_and_pointers_as_media):
            return Modality.TEXT

        try:
            modality = infer_modality(tensor_field.field_content, self.add_docs_params.media_download_headers)
        except MediaDownloadError as err:
            raise AddDocumentsError(f"Error processing {tensor_field.field_name}: {err.message}") from err

        if not self.marqo_index.treat_urls_and_pointers_as_media and modality in {Modality.AUDIO, Modality.VIDEO}:
            return Modality.TEXT

        return modality
Infer the modality of a tensor field. This is used for both unstructured and semi-structured indexes.

        We only infer the field type if the index is configured to treat URLs and pointers as images or media.

        treatUrlsAndPointersAsMedia is a new parameter introduced in Marqo 2.12 to support the new modalities
        of video and audio. Here is how it interacts with treatUrlsAndPointersAsImages:
        - Both False: All content is processed as text only
        - treatUrlsAndPointersAsImages True, treatUrlsAndPointersAsMedia False: Processes URLs and pointers as images.
        Other media types (video, audio) are treated as text
        - treatUrlsAndPointersAsImages False, treatUrlsAndPointersAsMedia True: Invalid state since this is a conflict
        - Both True: Processes URLs and pointers as various media types (images, videos, audio)

        The values of treatUrlsAndPointersAsMedia and treatUrlsAndPointersAsImages are validated in the MarqoIndex
        class, so we do not need to validate them here.

        Args:
            tensor_field: The tensor field to infer the modality.
        Returns:
            The inferred modality
        Raises:
            AddDocumentsError: If the modality of the media content cannot be inferred.
        
src/marqo/core/unstructured_vespa_index/unstructured_add_document_handler.py