docstr: Saves the output of the model to a CSV file.
  
  This hook assumes the dataset provides an "id" key. It also expects the
  task to provide an output of shape (B, C) where B is the batch size and
  C is the number of classes. Targets can be either one-hot encoded or
  single numbers.
code: def on_step(self, task) -> None:
      """Saves the output of the model to a CSV file.
  
      This hook assumes the dataset provides an "id" key. It also expects the
      task to provide an output of shape (B, C) where B is the batch size and
      C is the number of classes. Targets can be either one-hot encoded or
      single numbers."""
  
      if self.id_key not in task.last_batch.sample:
          return
  
      if task.train:
          return
  
      assert (
          len(task.last_batch.output.shape) == 2
      ), "First dimension must be batch size, second is the class logits"
      assert len(task.last_batch.sample["target"].shape) in [
          1,
          2,
      ], "Target must be integer or one-hot encoded vectors"
  
      sample_ids = task.last_batch.sample[self.id_key].tolist()
      predictions = task.last_batch.output.argmax(dim=1).tolist()
      target = task.last_batch.sample["target"]
      # One-hot encoded vectors
      if len(target.shape) == 2:
          targets = target.argmax(dim=1)
      targets = target.tolist()
  
      for sample_id, prediction, target in zip(
          sample_ids, predictions, targets
      ):
          self.file.write(
              self.delimiter.join(
                  [str(sample_id), str(prediction), str(target)]
              )
              + "\n"
          )
  
file_path: ClassyVision/classy_vision/hooks/output_csv_hook.py
imports: from classy_vision.hooks import register_hook
  from classy_vision.hooks.classy_hook import ClassyHook
  from fvcore.common.file_io import PathManager
label_desc: Use image node_id 3 for calling the OutputCSVHook obj's underlying member method code with example usage: obj.on_step(task) without return types