code: def duplicate_filename(path: str | Path) -> Path:
      """Check and duplicate filename.
  
      This function checks the path and adds a suffix if it already exists on the file system.
  
      Args:
          path (str | Path): Input Path
  
      Examples:
          >>> path = Path("datasets/MVTec/bottle/test/broken_large/000.png")
          >>> path.exists()
          True
  
          If we pass this to ``duplicate_filename`` function we would get the following:
          >>> duplicate_filename(path)
          PosixPath('datasets/MVTec/bottle/test/broken_large/000_1.png')
  
      Returns:
          Path: Duplicated output path.
      """
  
      if isinstance(path, str):
          path = Path(path)
  
      i = 0
      while True:
          duplicated_path = (
              path
              if i == 0
              else path.parent / (path.stem + f"_{i}" + path.suffix)
          )
          if not duplicated_path.exists():
              break
          i += 1
  
      return duplicated_path
  
file_path: anomalib/src/anomalib/data/utils/image.py
imports: from __future__ import annotations
  import math
  import warnings
  from pathlib import Path
  import cv2
  import numpy
  import tifffile
  import torch.nn.functional
  from torch import Tensor
  from torchvision.datasets.folder import IMG_EXTENSIONS
label_desc: Use image node_id 2 for calling a global function with example usage: duplicate_filename(path) and returns: duplicated_path