code: def get_batch(
      generator, batch_size, num_steps, max_word_length, pad=False
  ):
      """Read batches of input."""
      cur_stream = [None] * batch_size
  
      inputs = np.zeros([batch_size, num_steps], np.int32)
      char_inputs = np.zeros(
          [batch_size, num_steps, max_word_length], np.int32
      )
      global_word_ids = np.zeros([batch_size, num_steps], np.int32)
      targets = np.zeros([batch_size, num_steps], np.int32)
      weights = np.ones([batch_size, num_steps], np.float32)
  
      no_more_data = False
      while True:
          inputs[:] = 0
          char_inputs[:] = 0
          global_word_ids[:] = 0
          targets[:] = 0
          weights[:] = 0.0
  
          for i in range(batch_size):
              cur_pos = 0
  
              while cur_pos < num_steps:
                  if (
                      cur_stream[i] is None
                      or len(cur_stream[i][0]) <= 1
                  ):
                      try:
                          cur_stream[i] = list(generator.next())
                      except StopIteration:
                          # No more data, exhaust current streams and quit
                          no_more_data = True
                          break
  
                  how_many = min(
                      len(cur_stream[i][0]) - 1, num_steps - cur_pos
                  )
                  next_pos = cur_pos + how_many
  
                  inputs[i, cur_pos:next_pos] = cur_stream[i][0][
                      :how_many
                  ]
                  char_inputs[i, cur_pos:next_pos] = cur_stream[i][1][
                      :how_many
                  ]
                  global_word_ids[i, cur_pos:next_pos] = cur_stream[i][
                      2
                  ][:how_many]
                  targets[i, cur_pos:next_pos] = cur_stream[i][0][
                      1 : how_many + 1
                  ]
                  weights[i, cur_pos:next_pos] = 1.0
  
                  cur_pos = next_pos
                  cur_stream[i][0] = cur_stream[i][0][how_many:]
                  cur_stream[i][1] = cur_stream[i][1][how_many:]
                  cur_stream[i][2] = cur_stream[i][2][how_many:]
  
                  if pad:
                      break
  
          if no_more_data and np.sum(weights) == 0:
              # There is no more data and this is an empty batch. Done!
              break
          yield inputs, char_inputs, global_word_ids, targets, weights
  
imports: import random
  import numpy
  from textattack.shared.utils import LazyLoader
label_desc: Use image node_id 1 for calling a global function with example usage: get_batch(generator, batch_size, num_steps, max_word_length, pad) without return types