def validate_query_and_context(cls, values):
        """Validate that one of query and context are present for tensor/hybrid search, or just the query for lexical search.

        Raises:
            InvalidArgError: If validation fails
        """
        search_method = values.get('searchMethod')
        query = values.get('q')
        context = values.get('context')
        hybrid_parameters = values.get('hybridParameters')

        if search_method not in [SearchMethod.TENSOR, SearchMethod.HYBRID, SearchMethod.LEXICAL]:
            raise ValueError(f"Invalid search method {search_method}")

        if query is None:
            if search_method == SearchMethod.LEXICAL:
                raise ValueError("Query(q) is required for lexical search")
            elif search_method == SearchMethod.TENSOR:
                if context is None:
                    raise ValueError(
                        f"One of Query(q) or context is required for {search_method} search but both are missing"
                    )
            elif search_method == SearchMethod.HYBRID:
                if context is None and (not hybrid_parameters or (
                        hybrid_parameters.queryTensor is None and hybrid_parameters.queryLexical is None
                    )
                ):
                    raise ValueError(
                        f"One of Query(q), context, hybridParameters.queryTensor, or "
                        f"hybridParameters.queryTensor is required for {search_method} search but all are missing"
                    )
        else:
            if search_method == SearchMethod.HYBRID:
                if cls is SearchQuery:
                    # This check is needed because BulkSearchQuery inherits SearchQuery and because of the way we set
                    # query for it, it causes this check to fail since we previously provided queryTensor/queryLexical
                    # parameters
                    if hybrid_parameters is not None and (hybrid_parameters.queryTensor is not None or hybrid_parameters.queryLexical is not None):
                        raise ValueError(
                            f"Query(q) cannot be provided for {search_method} search when hybridParameters.queryTensor or "
                            f"hybridParameters.queryLexical is provided"
                        )

        return values
Validate that one of query and context are present for tensor/hybrid search, or just the query for lexical search.

        Raises:
            InvalidArgError: If validation fails
        
src/marqo/tensor_search/models/api_models.py