docstr: Called when StopIteration is triggered.
docstr_tok: ["Called","when","StopIteration","is","triggered","."]
code: def done(self) -> List[str]:
      """Called when StopIteration is triggered."""
      filepaths: List[str] = []
      if self.filled:
          return filepaths
  
      # Try writing down an chunks
      while self._should_write():
          filepaths.append(self.write_chunk())
  
      # If any elements is left, try writing one last chunk
      if self._serialized_items:
          filepaths.append(self.write_chunk(True))
  
      # Write down the index file
      self.write_chunks_index()
  
      self._is_done = True
      return filepaths
  
imports: import json
  import os
  import warnings
  from dataclasses import dataclass
  from time import sleep
  from typing import Any, Dict, List, Optional, Tuple, Union
  import numpy
  import torch
  from lightning.data.streaming.compression import _COMPRESSORS, Compressor
  from lightning.data.streaming.constants import _INDEX_FILENAME, _TORCH_GREATER_EQUAL_2_1_0
  from lightning.data.streaming.serializers import Serializer, _get_serializers
  from lightning.data.utilities.env import _DistributedEnv, _WorkerEnv
  from lightning.data.utilities.format import _convert_bytes_to_int, _human_readable_bytes
label_desc: Use image node_id 15 for calling the BinaryWriter obj's underlying member method code with example usage: obj.done() and returns: filepaths, filepaths