code: def write_results_to_uea_format(
      estimator_name,
      dataset_name,
      y_pred,
      output_path,
      full_path=True,
      y_true=None,
      predicted_probs=None,
      split="TEST",
      resample_seed=0,
      timing_type="N/A",
      first_line_comment=None,
      second_line="No Parameter Info",
      third_line="N/A",
  ):
      """Write the predictions for an experiment in the standard format used by sktime.
  
      Parameters
      ----------
      estimator_name : str,
          Name of the object that made the predictions, written to file and can
          determine file structure of output_root is True
      dataset_name : str
          name of the problem the classifier was built on
      y_pred : np.array
          predicted values
      output_path : str
          Path where to put results. Either a root path, or a full path
      full_path : boolean, default = True
          If False, then the standard file structure is created. If false, results are
          written directly to the directory passed in output_path
      y_true : np.array, default = None
          Actual values, written to file with the predicted values if present
      predicted_probs :  np.ndarray, default = None
          Estimated class probabilities. If passed, these are written after the
          predicted values. Regressors should not pass anything
      split : str, default = "TEST"
          Either TRAIN or TEST, depending on the results, influences file name.
      resample_seed : int, default = 0
          Indicates what data
      timing_type : str or None, default = None
          The format used for timings in the file, i.e. Seconds, Milliseconds, Nanoseconds
      first_line_comment : str or None, default = None
          Optional comment appended to the end of the first line
      second_line : str
          unstructured, used for predictor parameters
      third_line : str
          summary performance information (see comment below)
      """
      if len(y_true) != len(y_pred):
          raise IndexError(
              "The number of predicted values is not the same as the "
              "number of actual class values"
          )
      # If the full directory path is not passed, make the standard structure
      if not full_path:
          output_path = f"{output_path}/{estimator_name}/Predictions/{dataset_name}/"
      try:
          os.makedirs(output_path)
      except OSError:
          pass  # raises os.error if path already exists, so just ignore this
  
      if split == "TRAIN" or split == "train":
          train_or_test = "train"
      elif split == "TEST" or split == "test":
          train_or_test = "test"
      else:
          raise ValueError(
              "Unknown 'split' value - should be TRAIN/train or TEST/test"
          )
      file = open(
          f"{output_path}/{train_or_test}Resample{resample_seed}.csv",
          "w",
      )
      # the first line of the output file is in the form of:
      # <classifierName>,<datasetName>,<train/test>
      first_line = f"{dataset_name},{estimator_name},{train_or_test},{resample_seed}"
      if timing_type is not None:
          first_line += "," + timing_type
      if first_line_comment is not None:
          first_line += "," + first_line_comment
      file.write(first_line + "\n")
      # the second line of the output is free form and estimator-specific; usually this
      # will record info such as build time, parameter options used, any constituent model
      # names for ensembles, etc.
      file.write(str(second_line) + "\n")
      # the third line of the file is the accuracy (should be between 0 and 1
      # inclusive). If this is a train output file then it will be a training estimate
      # of the classifier on the training data only (e.g. 10-fold cv, leave-one-out cv,
      # etc.). If this is a test output file, it should be the output of the estimator
      # on the test data (likely trained on the training data for a-priori parameter
      # optimisation)
      file.write(str(third_line) + "\n")
      # from line 4 onwards each line should include the actual and predicted class
      # labels (comma-separated). If present, for each case, the probabilities of
      # predicting every class value for this case should also be appended to the line (
      # a space is also included between the predicted value and the predict_proba). E.g.:
      #
      # if predict_proba data IS provided for case i:
      #   y_true[i], y_pred[i],,prob_class_0[i],
      #   prob_class_1[i],...,prob_class_c[i]
      #
      # if predict_proba data IS NOT provided for case i:
      #   y_true[i], y_pred[i]
      # If y_true is None (if clustering), y_true[i] is replaced with ? to indicate
      # missing
      if y_true is None:
          for i in range(0, len(y_pred)):
              file.write("?," + str(y_pred[i]))
              if predicted_probs is not None:
                  file.write(",")
                  for j in predicted_probs[i]:
                      file.write("," + str(j))
              file.write("\n")
      else:
          for i in range(0, len(y_pred)):
              file.write(str(y_true[i]) + "," + str(y_pred[i]))
              if predicted_probs is not None:
                  file.write(",")
                  for j in predicted_probs[i]:
                      file.write("," + str(j))
              file.write("\n")
      file.close()
  
imports: import os
  import textwrap
label_desc: Use image node_id 4 for calling a global function with example usage: write_results_to_uea_format(estimator_name, dataset_name, y_pred, output_path, full_path, y_true, predicted_probs, split, resample_seed, timing_type, first_line_comment, second_line, third_line) without return types