code: def dumps_with_persistent_ids(obj, protocol=None):
      """
      Performs a pickle dumps on the given object, substituting all references to
      a TradingEnvironment or AssetFinder with tokenized representations.
  
      All arguments are passed to pickle.Pickler and are described therein.
      """
      file = BytesIO()
      pickler = pickle.Pickler(file, protocol)
      pickler.persistent_id = _persistent_id
      pickler.dump(obj)
      return file.getvalue()
  
file_path: catalyst/catalyst/utils/serialization_utils.py
imports: from six import BytesIO
  import pickle
  from functools import partial
  from catalyst.assets import AssetFinder
  from catalyst.finance.trading import TradingEnvironment
label_desc: Use image node_id 3 for calling a global function with example usage: dumps_with_persistent_ids(obj, protocol) and returns: file