def text_transform(text, tokenizer, max_len=MAX_SEQ_LEN):
        """
        Text transformation function for sequence classification.
        The function can be passed to a map-style PyTorch DataSet.

        Args:
            text (str): Input text.
            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.
        """
        if max_len > MAX_SEQ_LEN:
            print("setting max_len to max allowed seq length: {}".format(MAX_SEQ_LEN))
            max_len = MAX_SEQ_LEN
        # truncate and add CLS & SEP markers
        tokens = tokenizer.tokenize(text)[0 : max_len - 2]
        tokens = [tokenizer.cls_token] + tokens + [tokenizer.sep_token]

        # get input ids
        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]
        # create segment ids
        token_type_ids = [0] * len(input_ids)

        return input_ids, attention_mask, token_type_ids

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

        Args:
            text (str): Input text.
            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