code: def _pickle_to_temp_location_or_memory(obj):
      """
      If obj can be serialized directly into memory (via cloudpickle) this
      will return the serialized bytes.
      Otherwise, gl_pickle is attempted and it will then
      generates a temporary directory serializes an object into it, returning
      the directory name. This directory will not have lifespan greater than
      that of unity_server.
      """
      from . import _cloudpickle as cloudpickle
  
      try:
          # try cloudpickle first and see if that works
          lambda_str = cloudpickle.dumps(obj)
          return lambda_str
      except:
          pass
  
      # nope. that does not work! lets try again with gl pickle
      filename = _make_temp_filename("pickle")
      from .. import _gl_pickle
  
      pickler = _gl_pickle.GLPickler(filename)
      pickler.dump(obj)
      pickler.close()
      return filename
  
imports: from __future__ import print_function
  from __future__ import division
  from __future__ import absolute_import
  import os
  import urllib
  import re
  import itertools
  import uuid
  import datetime
  import sys
  from ._sframe_generation import generate_random_sframe
  from ._sframe_generation import generate_random_regression_sframe
  from ._sframe_generation import generate_random_classification_sframe
  from ._type_checks import _raise_error_if_not_of_type
  from ._type_checks import _is_non_string_iterable
  from ._progress_table_printer import ProgressTablePrinter
label_desc: Use image node_id 14 for calling a global function with example usage: _pickle_to_temp_location_or_memory(obj) and returns: filename, lambda_str