code: def encode_document(
      self, document: PersonDocument
  ) -> "HANEncodedDocument":
      prefix_sentence = ["[CLS]"] + Background.get_sentence(
          document.background
      )
      sentences = [prefix_sentence] + [s for s in document.sentences]
  
      abspos = [0.0] + document.abspos[-self.sentence_num + 1 :]
      age = [0.0] + document.age[-self.sentence_num + 1 :]
      position = np.zeros((2, self.sentence_num))
      position[0, 0 : len(abspos)] = abspos
      position[1, 0 : len(age)] = age
  
      token2index = self.datamodule.vocabulary.token2index
      unk_id = token2index["[UNK]"]
  
      token_ids = np.zeros((self.sentence_num, self.word_num))
  
      for i, j in enumerate(sentences[-self.sentence_num :]):
          token_ids[i][0 : len(j)] = list(
              map(
                  lambda x: token2index.get(x, unk_id),
                  j,
              ),
          )
  
      target = np.array(document.task_info).astype(int)
      sequence_id = np.array(document.person_id)
  
      return HANEncodedDocument(
          sequence_id=sequence_id,
          input_ids=token_ids,
          padding_mask=token_ids.astype(bool),
          target=target,
          position=position,
          original_sequence=token_ids,
      )
  
imports: from dataclasses import dataclass
  from doctest import ELLIPSIS_MARKER
  from itertools import chain
  from typing import List, TypeVar, cast
  import numpy
  import pandas
  from src.data_new.types import Background, JSONSerializable, PersonDocument, EncodedDocument
  from src.tasks.base import Task
label_desc: Use image node_id 1 for calling the CLS_HAN obj's underlying member method code with example usage: obj.encode_document(document) and returns: HANEncodedDocument