docstr: Once all the workers have written their own index, the merge function is responsible to read and merge them
  into a single index.
docstr_tok: ["Once","all","the","workers","have","written","their","own","index",",","the","merge","function","is","responsible","to","read","and","merge","them","into","a","single","index","."]
code: def _merge_no_wait(self, node_rank: Optional[int] = None) -> None:
      """Once all the workers have written their own index, the merge function is responsible to read and merge them
      into a single index."""
      files = os.listdir(self._cache_dir)
      index_files = [f for f in files if f.endswith(_INDEX_FILENAME)]
  
      chunks_info = []
      config = None
      for index_filename in sorted(index_files):
          chunk_path = os.path.join(self._cache_dir, index_filename)
          with open(chunk_path) as f:
              data = json.load(f)
  
              if config is None:
                  config = data["config"]
  
              elif config != data["config"]:
                  breakpoint()
                  raise Exception(
                      "The config isn't consistent between chunks. This shouldn't have happened."
                  )
  
              chunks_info.extend(data["chunks"])
  
          os.remove(chunk_path)
  
      if node_rank is None:
          with open(
              os.path.join(self._cache_dir, _INDEX_FILENAME), "w"
          ) as f:
              json.dump(
                  {"chunks": chunks_info, "config": config},
                  f,
                  sort_keys=True,
              )
      else:
          with open(
              os.path.join(
                  self._cache_dir, f"{node_rank}-{_INDEX_FILENAME}"
              ),
              "w",
          ) as f:
              json.dump(
                  {"chunks": chunks_info, "config": config},
                  f,
                  sort_keys=True,
              )
  
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 17 for calling the BinaryWriter obj's underlying member method code with example usage: obj._merge_no_wait(node_rank) without return types