code: def _try_create_cache_dir(
      input_dir: str, shard_rank: int = 0
  ) -> Optional[str]:
      hash_object = hashlib.md5(input_dir.encode())
      if (
          "LIGHTNING_CLUSTER_ID" not in os.environ
          or "LIGHTNING_CLOUD_PROJECT_ID" not in os.environ
      ):
          cache_dir = os.path.join(
              _DEFAULT_CACHE_DIR,
              hash_object.hexdigest(),
              str(shard_rank),
          )
          os.makedirs(cache_dir, exist_ok=True)
          return cache_dir
      cache_dir = os.path.join(
          "/cache", "chunks", hash_object.hexdigest(), str(shard_rank)
      )
      os.makedirs(cache_dir, exist_ok=True)
      return cache_dir
  
imports: import hashlib
  import os
  from dataclasses import dataclass
  from time import time
  from typing import Any, Dict, List, Optional, Tuple, Union
  import numpy
  from torch.utils.data import IterableDataset, get_worker_info
  from lightning.data.streaming import Cache
  from lightning.data.streaming.constants import _DEFAULT_CACHE_DIR, _INDEX_FILENAME, _LIGHTNING_CLOUD_LATEST
  from lightning.data.streaming.item_loader import BaseItemLoader
  from lightning.data.streaming.sampler import ChunkedIndex
  from lightning.data.streaming.serializers import Serializer
  from lightning.data.streaming.shuffle import FullShuffle, NoShuffle, Shuffle
  from lightning.data.utilities.env import Environment, _DistributedEnv, _WorkerEnv
label_desc: Use image node_id 1 for calling a global function with example usage: _try_create_cache_dir(input_dir, shard_rank) and returns: cache_dir, cache_dir