code: def generate_batch(batch_size, num_skips, skip_window):
      assert num_skips <= 2 * skip_window
      # Adjust batch_size to match num_skips
      batch_size = batch_size // num_skips * num_skips
      span = 2 * skip_window + 1  # [ skip_window target skip_window ]
      # Backtrack a little bit to avoid skipping words in the end of a batch
      data_index = random.randint(0, len(data) - span - 1)
      batch = np.ndarray(shape=(batch_size), dtype=np.int32)
      labels = np.ndarray(shape=(batch_size, 1), dtype=np.int32)
      buffer = collections.deque(maxlen=span)
      for _ in range(span):
          buffer.append(data[data_index])
          data_index = (data_index + 1) % len(data)
      for i in range(batch_size // num_skips):
          target = (
              skip_window  # target label at the center of the buffer
          )
          targets_to_avoid = [skip_window]
          for j in range(num_skips):
              while target in targets_to_avoid:
                  target = random.randint(0, span - 1)
              targets_to_avoid.append(target)
              batch[i * num_skips + j] = buffer[skip_window]
              labels[i * num_skips + j, 0] = buffer[target]
          buffer.append(data[data_index])
          data_index = (data_index + 1) % len(data)
      return batch, labels
  
file_path: horovod/examples/tensorflow/tensorflow_word2vec.py
imports: import collections
  import math
  import os
  import random
  import urllib
  import zipfile
  import numpy
  import tensorflow
  import horovod.tensorflow
label_desc: Use image node_id 4 for calling a global function with example usage: generate_batch(batch_size, num_skips, skip_window) and returns: batch,  labels