docstr: Add a pre-save/load callback for weights files and return its handle. If the callback was already added,
   return the existing handle.
  
  Use this callback to modify the weights filename registered in the ClearML Server. In case ClearML is
   configured to upload the weights file, this will affect the uploaded filename as well.
   Callback returning None will disable the tracking of the current call Model save,
   it will not disable saving it to disk, just the logging/tracking/uploading.
  
  :param callback_function: A function accepting action type ("load" or "save"),
      callback_function('load' or 'save', WeightsFileHandler.ModelInfo) -> WeightsFileHandler.ModelInfo
  :return Callback handle
docstr_tok: ["Add","a","pre-save\/load","callback","for","weights","files","and","return","its","handle",".","If","the","callback","was","already","added",",","return","the","existing","handle",".","Use","this","callback","to","modify","the","weights","filename","registered","in","the","ClearML","Server",".","In","case","ClearML","is","configured","to","upload","the","weights","file",",","this","will","affect","the","uploaded","filename","as","well",".","Callback","returning","None","will","disable","the","tracking","of","the","current","call","Model","save",",","it","will","not","disable","saving","it","to","disk",",","just","the","logging\/tracking\/uploading",".",":","param","callback_function",":","A","function","accepting","action","type","(","``","load","''","or","``","save","''",")",",","callback_function","(","'load","'","or","'save","'",",","WeightsFileHandler.ModelInfo",")","-",">","WeightsFileHandler.ModelInfo",":","return","Callback","handle"]
code: def add_pre_callback(cls, callback_function):
      # type: (Callable[[Union[str, WeightsFileHandler.CallbackType], WeightsFileHandler.ModelInfo], Optional[WeightsFileHandler.ModelInfo]]) -> int  # noqa
      """
      Add a pre-save/load callback for weights files and return its handle. If the callback was already added,
       return the existing handle.
  
      Use this callback to modify the weights filename registered in the ClearML Server. In case ClearML is
       configured to upload the weights file, this will affect the uploaded filename as well.
       Callback returning None will disable the tracking of the current call Model save,
       it will not disable saving it to disk, just the logging/tracking/uploading.
  
      :param callback_function: A function accepting action type ("load" or "save"),
          callback_function('load' or 'save', WeightsFileHandler.ModelInfo) -> WeightsFileHandler.ModelInfo
      :return Callback handle
      """
      return cls._add_callback(
          callback_function, cls._model_pre_callbacks
      )
  
imports: import os
  import shutil
  import sys
  import threading
  from enum import Enum
  from random import randint
  from tempfile import mkstemp
  from typing import TYPE_CHECKING, Callable, Dict, Optional, Any, Union
  import six
  from pathlib2 import Path
  from ...backend_interface.model import Model
  from ...config import running_remotely
  from ...debugging.log import get_logger
  from ...model import InputModel, OutputModel
label_desc: Use image node_id 3 for calling the WeightsFileHandler obj's underlying member method code with example usage: obj.add_pre_callback(cls, callback_function) and returns: cls