code: def convert(
      file_in,
      file_out,
      features_start,
      features_dim,
      labels_start,
      labels_dim,
      num_labels,
      label_type="Category",
      mapping_file=None,
  ):
      label_map = {}
      if label_type == "Category":
          if mapping_file is not None:
              with open(mapping_file, "r") as f:
                  for line in f.read().splitlines():
                      label_map[line] = len(label_map)
  
              num_labels = max(num_labels, len(label_map))
          else:
              label_map = {str(x): x for x in range(num_labels)}
  
      input_file = open(file_in, "r")
      output_file = open(file_out, "w")
  
      for line in input_file.readlines():
          values = line.split()
  
          if label_type != "None":
              max_length = max(
                  labels_start + labels_dim,
                  features_start + features_dim,
              )
              if len(values) < (labels_dim + features_dim):
                  raise RuntimeError(
                      (
                          "Too few input columns ({} out of expected {}) "
                      ).format(len(values), (labels_dim + features_dim))
                  )
              elif len(values) < max_length:
                  raise RuntimeError(
                      (
                          "Too few input columns ({} out of expected {}) "
                      ).format(len(values), max_length)
                  )
  
              labels = values[labels_start : labels_start + labels_dim]
  
              if label_type == "Category":
                  one_hot = ["0"] * num_labels
                  # there's only one label
                  label = labels[0]
                  if label not in label_map:
                      raise RuntimeError(
                          ("Illegal label value: '{}'").format(label)
                      )
                  one_hot[label_map[label]] = "1"
                  labels = one_hot
  
              output_file.write("|labels " + " ".join(labels))
              output_file.write("\t")
  
          elif len(values) < features_start + features_dim:
              raise RuntimeError(
                  (
                      "Too few input columns ({} out of expected {}) "
                  ).format(len(values), features_start + features_dim)
              )
  
          output_file.write(
              "|features "
              + " ".join(
                  values[features_start : features_start + features_dim]
              )
          )
          output_file.write("\n")
  
      input_file.close()
      output_file.close()
  
label_desc: Use image node_id 1 for calling a global function with example usage: convert(file_in, file_out, features_start, features_dim, labels_start, labels_dim, num_labels, label_type, mapping_file) without return types