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 hash for a single image.
  
  Args:
      image_file: Path to the image file.
      image_array: Optional, used instead of image_file. Image typecast to numpy array.
  
  Returns:
      hash: A 16 character hexadecimal string hash for the image.
  
  Example:
  ```
  from imagededup.methods import <hash-method>
  myencoder = <hash-method>()
  myhash = myencoder.encode_image(image_file='path/to/image.jpg')
  OR
  myhash = myencoder.encode_image(image_array=<numpy array of image>)
  ```
docstr_tok: ["Generate","hash","for","a","single","image",".","Args",":","image_file",":","Path","to","the","image","file",".","image_array",":","Optional",",","used","instead","of","image_file",".","Image","typecast","to","numpy","array",".","Returns",":","hash",":","A","16","character","hexadecimal","string","hash","for","the","image",".","Example",":","``","`","from","imagededup.methods","import","<","hash-method",">","myencoder","=","<","hash-method",">","(",")","myhash","=","myencoder.encode_image","(","image_file='path\/to\/image.jpg","'",")","OR","myhash","=","myencoder.encode_image","(","image_array=","<","numpy","array","of","image",">",")","``","`"]
code: def encode_image(
      self, image_file=None, image_array: Optional[np.ndarray] = None
  ) -> str:
      """
      Generate hash for a single image.
  
      Args:
          image_file: Path to the image file.
          image_array: Optional, used instead of image_file. Image typecast to numpy array.
  
      Returns:
          hash: A 16 character hexadecimal string hash for the image.
  
      Example:
      ```
      from imagededup.methods import <hash-method>
      myencoder = <hash-method>()
      myhash = myencoder.encode_image(image_file='path/to/image.jpg')
      OR
      myhash = myencoder.encode_image(image_array=<numpy array of image>)
      ```
      """
      try:
          if image_file and os.path.exists(image_file):
              image_file = Path(image_file)
              image_pp = load_image(
                  image_file=image_file,
                  target_size=self.target_size,
                  grayscale=True,
              )
  
          elif isinstance(image_array, np.ndarray):
              check_image_array_hash(
                  image_array
              )  # Do sanity checks on array
              image_pp = preprocess_image(
                  image=image_array,
                  target_size=self.target_size,
                  grayscale=True,
              )
          else:
              raise ValueError
      except (ValueError, TypeError):
          raise ValueError(
              "Please provide either image file path or image array!"
          )
  
      return (
          self._hash_func(image_pp)
          if isinstance(image_pp, np.ndarray)
          else None
      )
  
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 4 for calling the Hashing obj's underlying member method code with example usage: obj.encode_image(image_file, image_array) and returns: unknown