code: def _tensor_inference(model, input_sample_list, batch_size):
      if batch_size is None:
          # this branch is only to speed up the inferencing when batch_size is set to None.
          return model(*input_sample_list).numpy()
      else:
          yhat_list = []
          sample_num = input_sample_list[0].shape[
              0
          ]  # the first dim should be sample_num
          if sample_num <= batch_size:
              return model(*input_sample_list).numpy()
          else:
              batch_num = math.ceil(sample_num / batch_size)
              for batch_id in range(batch_num):
                  yhat_list.append(
                      model(
                          *tuple(
                              map(
                                  lambda x: x[
                                      batch_id
                                      * batch_size : (batch_id + 1)
                                      * batch_size
                                  ],
                                  input_sample_list,
                              )
                          )
                      ).numpy()
                  )
              # this operation may cause performance degradation
              yhat = np.concatenate(yhat_list, axis=0)
              return yhat
  
imports: import math
  import torch
  import numpy
  from torch.utils.data.dataloader import DataLoader
label_desc: Use image node_id 1 for calling a global function with example usage: _tensor_inference(model, input_sample_list, batch_size) and returns: model, model, yhat