class_docstr: Find duplicates using hashing algorithms and/or generate hashes given a single image or a directory of images.
  
  The module can be used for 2 purposes: Encoding generation and duplicate detection.
  - Encoding generation:
  To generate hashes using specific hashing method. The generated hashes can be used at a later time for
  deduplication. Using the method 'encode_image' from the specific hashing method object, the hash for a
  single image can be obtained while the 'encode_images' method can be used to get hashes for all images in a
  directory.
  
  - Duplicate detection:
  Find duplicates either using the encoding mapping generated previously using 'encode_images' or using a Path to the
  directory that contains the images that need to be deduplicated. 'find_duplicates' and 'find_duplicates_to_remove'
  methods are provided to accomplish these tasks.
docstr: Generate hashes for all images in a given directory of images.
  
  Args:
      image_dir: Path to the image directory.
      recursive: Optional, find images recursively in a nested image directory structure, set to False by default.
      num_enc_workers: Optional, number of cpu cores to use for multiprocessing encoding generation, set to number of CPUs in the system by default. 0 disables multiprocessing.
  
  Returns:
      dictionary: A dictionary that contains a mapping of filenames and corresponding 64 character hash string
                  such as {'Image1.jpg': 'hash_string1', 'Image2.jpg': 'hash_string2', ...}
  
  Example:
  ```
  from imagededup.methods import <hash-method>
  myencoder = <hash-method>()
  mapping = myencoder.encode_images('path/to/directory')
  ```
docstr_tok: ["Generate","hashes","for","all","images","in","a","given","directory","of","images",".","Args",":","image_dir",":","Path","to","the","image","directory",".","recursive",":","Optional",",","find","images","recursively","in","a","nested","image","directory","structure",",","set","to","False","by","default",".","num_enc_workers",":","Optional",",","number","of","cpu","cores","to","use","for","multiprocessing","encoding","generation",",","set","to","number","of","CPUs","in","the","system","by","default",".","0","disables","multiprocessing",".","Returns",":","dictionary",":","A","dictionary","that","contains","a","mapping","of","filenames","and","corresponding","64","character","hash","string","such","as","{","'Image1.jpg","'",":","'hash_string1","'",",","'Image2.jpg","'",":","'hash_string2","'",",","...","}","Example",":","``","`","from","imagededup.methods","import","<","hash-method",">","myencoder","=","<","hash-method",">","(",")","mapping","=","myencoder.encode_images","(","'path\/to\/directory","'",")","``","`"]
code: def encode_images(
      self,
      image_dir=None,
      recursive: bool = False,
      num_enc_workers: int = cpu_count(),
  ):
      """
      Generate hashes for all images in a given directory of images.
  
      Args:
          image_dir: Path to the image directory.
          recursive: Optional, find images recursively in a nested image directory structure, set to False by default.
          num_enc_workers: Optional, number of cpu cores to use for multiprocessing encoding generation, set to number of CPUs in the system by default. 0 disables multiprocessing.
  
      Returns:
          dictionary: A dictionary that contains a mapping of filenames and corresponding 64 character hash string
                      such as {'Image1.jpg': 'hash_string1', 'Image2.jpg': 'hash_string2', ...}
  
      Example:
      ```
      from imagededup.methods import <hash-method>
      myencoder = <hash-method>()
      mapping = myencoder.encode_images('path/to/directory')
      ```
      """
      if not os.path.isdir(image_dir):
          raise ValueError("Please provide a valid directory path!")
  
      files = generate_files(image_dir, recursive)
  
      logger.info(f"Start: Calculating hashes...")
  
      hashes = parallelise(
          function=self.encode_image,
          data=files,
          verbose=self.verbose,
          num_workers=num_enc_workers,
      )
      hash_initial_dict = dict(
          zip(generate_relative_names(image_dir, files), hashes)
      )
      hash_dict = {
          k: v for k, v in hash_initial_dict.items() if v
      }  # To ignore None (returned if some probelm with image file)
  
      logger.info(f"End: Calculating hashes!")
      return hash_dict
  
imports: import os
  import sys
  import warnings
  from pathlib import PurePath, Path
  from typing import Dict, List, Optional
  from multiprocessing import cpu_count
  import numpy
  import pywt
  from scipy.fftpack import dct
  from imagededup.handlers.search.retrieval import HashEval
  from imagededup.utils.general_utils import get_files_to_remove, save_json, parallelise, generate_files, generate_relative_names
  from imagededup.utils.image_utils import load_image, preprocess_image, check_image_array_hash
  from imagededup.utils.logger import return_logger
label_desc: Use image node_id 5 for calling the Hashing obj's underlying member method code with example usage: obj.encode_images(image_dir, recursive, num_enc_workers) and returns: hash_dict