def text_pair_transform(text_1, text_2, tokenizer, max_len=MAX_SEQ_LEN):
        """
        Text transformation function for sentence pair classification.
        The function can be passed to a map-style PyTorch DataSet.

        Args:
            text_1 (str): Input text 1.
            text_2 (str): Input text 2.
            tokenizer (PreTrainedTokenizer): A pretrained tokenizer.
            max_len (int, optional): Max sequence length. Defaults to 512.

        Returns:
            tuple: Tuple containing input ids, attention masks, and segment ids.
        """

        def _truncate_seq_pair(tokens_a, tokens_b, max_length):
            """Truncates a sequence pair in place to the maximum length."""
            # This is a simple heuristic which will always truncate the longer
            # sequence one token at a time. This makes more sense than
            # truncating an equal percent of tokens from each, since if one
            # sequence is very short then each token that's truncated likely
            # contains more information than a longer sequence.

            if not tokens_b:
                max_length += 1

            while True:
                total_length = len(tokens_a) + len(tokens_b)
                if total_length <= max_length:
                    break
                if len(tokens_a) > len(tokens_b):
                    tokens_a.pop()
                else:
                    tokens_b.pop()

            tokens_a.append(tokenizer.sep_token)

            if tokens_b:
                tokens_b.append(tokenizer.sep_token)

            return tokens_a, tokens_b

        if max_len > MAX_SEQ_LEN:
            print("setting max_len to max allowed tokens: {}".format(MAX_SEQ_LEN))
            max_len = MAX_SEQ_LEN

        tokens_1 = tokenizer.tokenize(text_1)

        tokens_2 = tokenizer.tokenize(text_2)

        tokens_1, tokens_2 = _truncate_seq_pair(tokens_1, tokens_2, max_len - 3)

        # construct token_type_ids, prefix with [0] for [CLS]
        # [0, 0, 0, 0, ... 0, 1, 1, 1, ... 1]
        token_type_ids = [0] + [0] * len(tokens_1) + [1] * len(tokens_2)
        # pad sequence
        token_type_ids = token_type_ids + [0] * (max_len - len(token_type_ids))
        # merge sentences
        tokens = [tokenizer.cls_token] + tokens_1 + tokens_2
        # convert tokens to indices
        input_ids = tokenizer.convert_tokens_to_ids(tokens)
        # pad sequence
        input_ids = input_ids + [0] * (max_len - len(input_ids))
        # create input mask
        attention_mask = [min(1, x) for x in input_ids]

        return input_ids, attention_mask, token_type_ids

        Text transformation function for sentence pair classification.
        The function can be passed to a map-style PyTorch DataSet.

        Args:
            text_1 (str): Input text 1.
            text_2 (str): Input text 2.
            tokenizer (PreTrainedTokenizer): A pretrained tokenizer.
            max_len (int, optional): Max sequence length. Defaults to 512.

        Returns:
            tuple: Tuple containing input ids, attention masks, and segment ids.
        
utils_nlp/models/transformers/sequence_classification.py