def _process_tensor_fields(cls, document: Dict, instance, marqo_index: SemiStructuredMarqoIndex):
        """Process tensor fields in the document"""
        vector_count = 0
        if constants.MARQO_DOC_TENSORS in document:
            for marqo_tensor_field, tensor_value in document[constants.MARQO_DOC_TENSORS].items():
                if instance.index_supports_partial_updates:
                    instance.fixed_fields.field_types[marqo_tensor_field] = MarqoFieldTypes.TENSOR.value # Set field_types as tensor for tensor fields

                    multimodal_params = document.get(MARQO_DOC_MULTIMODAL_PARAMS)
                    if multimodal_params is not None and multimodal_params.get(marqo_tensor_field) is not None: # Set field_types as tensor for sub-fields of multimodal combo fields
                        try:
                            multimodal_params = json.loads(document.get(MARQO_DOC_MULTIMODAL_PARAMS).get(marqo_tensor_field))
                            multimodal_combo_sub_fields = multimodal_params.get(MARQO_DOC_MULTIMODAL_PARAMS_WEIGHTS).keys()
                            for sub_field in multimodal_combo_sub_fields:
                                instance.fixed_fields.field_types[sub_field] = MarqoFieldTypes.TENSOR.value
                        except json.JSONDecodeError as e:
                            raise MarqoDocumentParsingError(f"Error parsing multimodal params for field {marqo_tensor_field}: {str(e)}")

                cls._verify_marqo_tensor_field_name(marqo_tensor_field, marqo_index)
                cls._verify_marqo_tensor_field(marqo_tensor_field, tensor_value)

                # If chunking an image, chunks will be a list of tuples, hence the str(c)
                chunks = [str(c) for c in tensor_value[constants.MARQO_DOC_CHUNKS]]
                embeddings = tensor_value[constants.MARQO_DOC_EMBEDDINGS]
                vector_count += len(embeddings)

                index_tensor_field = marqo_index.tensor_field_map[marqo_tensor_field]
                instance.tensor_fields[index_tensor_field.chunk_field_name] = chunks
                instance.tensor_fields[index_tensor_field.embeddings_field_name] = \
                    {f'{i}': embeddings[i] for i in range(len(embeddings))}

        return vector_count
Process tensor fields in the document
src/marqo/core/semi_structured_vespa_index/semi_structured_document.py