class_docstr: The implement of DialogReader.
code: def _gen_self_attn_mask(
      self,
      batch_token_ids,
      batch_tgt_start_idx=None,
      is_unidirectional=True,
      shift_len=0,
  ):
      max_len = max(map(len, batch_token_ids))
      input_mask_data = np.zeros(
          (
              len(batch_token_ids),
              max_len + shift_len,
              max_len + shift_len,
          )
      )
      if is_unidirectional:
          for index, mask_data in enumerate(input_mask_data):
              start = (
                  0
                  if batch_tgt_start_idx is None
                  else batch_tgt_start_idx[index]
              )
              end = len(batch_token_ids[index])
              mask_data[: end + shift_len, : start + shift_len] = 1.0
              # Generate the lower triangular matrix using the slice of matrix
              b = np.tril(np.ones([end - start, end - start]), 0)
              mask_data[
                  start + shift_len : end + shift_len,
                  start + shift_len : end + shift_len,
              ] = b
      else:
          for index, token_ids in enumerate(batch_token_ids):
              input_mask_data[
                  index,
                  : len(token_ids) + shift_len,
                  : len(token_ids) + shift_len,
              ] = 1.0
      return input_mask_data.astype("float32")
  
imports: import csv
  from collections import namedtuple
  from contextlib import contextmanager
  import gzip
  import numpy
  from ..utils import pad_batch_data
  from ..utils.args import str2bool
  from ..utils.masking import mask
  from ..utils import tokenization
label_desc: Use image node_id 12 for calling the DialogReader obj's underlying member method code with example usage: obj._gen_self_attn_mask(batch_token_ids, batch_tgt_start_idx, is_unidirectional, shift_len) and returns: input_mask_data