code: def _get_input_tensors_batch(self, samples_list, training=True):
      tokens_tensor_list = []
      bert_spans_tensor_list = []
      spans_ner_label_tensor_list = []
      sentence_length = []
  
      max_tokens = 0
      max_spans = 0
      for sample in samples_list:
          tokens = sample["tokens"]
          spans = sample["spans"]
          spans_ner_label = sample["spans_label"]
  
          (
              tokens_tensor,
              bert_spans_tensor,
              spans_ner_label_tensor,
          ) = self._get_input_tensors(tokens, spans, spans_ner_label)
          tokens_tensor_list.append(tokens_tensor)
          bert_spans_tensor_list.append(bert_spans_tensor)
          spans_ner_label_tensor_list.append(spans_ner_label_tensor)
          assert (
              bert_spans_tensor.shape[1]
              == spans_ner_label_tensor.shape[1]
          )
          if tokens_tensor.shape[1] > max_tokens:
              max_tokens = tokens_tensor.shape[1]
          if bert_spans_tensor.shape[1] > max_spans:
              max_spans = bert_spans_tensor.shape[1]
          sentence_length.append(sample["sent_length"])
      sentence_length = torch.Tensor(sentence_length)
  
      # apply padding and concatenate tensors
      final_tokens_tensor = None
      final_attention_mask = None
      final_bert_spans_tensor = None
      final_spans_ner_label_tensor = None
      final_spans_mask_tensor = None
      for (
          tokens_tensor,
          bert_spans_tensor,
          spans_ner_label_tensor,
      ) in zip(
          tokens_tensor_list,
          bert_spans_tensor_list,
          spans_ner_label_tensor_list,
      ):
          # padding for tokens
          num_tokens = tokens_tensor.shape[1]
          tokens_pad_length = max_tokens - num_tokens
          attention_tensor = torch.full(
              [1, num_tokens], 1, dtype=torch.long
          )
          if tokens_pad_length > 0:
              pad = torch.full(
                  [1, tokens_pad_length],
                  self.tokenizer.pad_token_id,
                  dtype=torch.long,
              )
              tokens_tensor = torch.cat((tokens_tensor, pad), dim=1)
              attention_pad = torch.full(
                  [1, tokens_pad_length], 0, dtype=torch.long
              )
              attention_tensor = torch.cat(
                  (attention_tensor, attention_pad), dim=1
              )
  
          # padding for spans
          num_spans = bert_spans_tensor.shape[1]
          spans_pad_length = max_spans - num_spans
          spans_mask_tensor = torch.full(
              [1, num_spans], 1, dtype=torch.long
          )
          if spans_pad_length > 0:
              pad = torch.full(
                  [1, spans_pad_length, bert_spans_tensor.shape[2]],
                  0,
                  dtype=torch.long,
              )
              bert_spans_tensor = torch.cat(
                  (bert_spans_tensor, pad), dim=1
              )
              mask_pad = torch.full(
                  [1, spans_pad_length], 0, dtype=torch.long
              )
              spans_mask_tensor = torch.cat(
                  (spans_mask_tensor, mask_pad), dim=1
              )
              spans_ner_label_tensor = torch.cat(
                  (spans_ner_label_tensor, mask_pad), dim=1
              )
  
          # update final outputs
          if final_tokens_tensor is None:
              final_tokens_tensor = tokens_tensor
              final_attention_mask = attention_tensor
              final_bert_spans_tensor = bert_spans_tensor
              final_spans_ner_label_tensor = spans_ner_label_tensor
              final_spans_mask_tensor = spans_mask_tensor
          else:
              final_tokens_tensor = torch.cat(
                  (final_tokens_tensor, tokens_tensor), dim=0
              )
              final_attention_mask = torch.cat(
                  (final_attention_mask, attention_tensor), dim=0
              )
              final_bert_spans_tensor = torch.cat(
                  (final_bert_spans_tensor, bert_spans_tensor), dim=0
              )
              final_spans_ner_label_tensor = torch.cat(
                  (
                      final_spans_ner_label_tensor,
                      spans_ner_label_tensor,
                  ),
                  dim=0,
              )
              final_spans_mask_tensor = torch.cat(
                  (final_spans_mask_tensor, spans_mask_tensor), dim=0
              )
      # logger.info(final_tokens_tensor)
      # logger.info(final_attention_mask)
      # logger.info(final_bert_spans_tensor)
      # logger.info(final_bert_spans_tensor.shape)
      # logger.info(final_spans_mask_tensor.shape)
      # logger.info(final_spans_ner_label_tensor.shape)
      return (
          final_tokens_tensor,
          final_attention_mask,
          final_bert_spans_tensor,
          final_spans_mask_tensor,
          final_spans_ner_label_tensor,
          sentence_length,
      )
  
imports: import os
  import sys
  import torch
  from torch import nn
  import torch.nn.functional
  from torch.nn import CrossEntropyLoss
  from allennlp.nn.util import batched_index_select
  from allennlp.nn import util
  from allennlp.modules import FeedForward
  import numpy
  from transformers import BertTokenizer, BertPreTrainedModel, BertModel
  from transformers import AlbertTokenizer, AlbertPreTrainedModel, AlbertModel
  import os
  import json
  import logging
label_desc: Use image node_id 4 for calling the EntityModel obj's underlying member method code with example usage: obj._get_input_tensors_batch(samples_list, training) and returns: final_tokens_tensor,  final_attention_mask,  final_bert_spans_tensor,  final_spans_mask_tensor,  final_spans_ner_label_tensor,  sentence_length