code: def use_obj_for_literal_in_memo(expr, obj, lit, memo):
      """
      Set `memo[node] = obj` for all nodes in expr such that `node.obj == lit`
  
      This is a useful routine for fmin-compatible functions that are searching
      domains that include some leaf nodes that are complicated
      runtime-generated objects. One option is to make such leaf nodes pyll
      functions, but it can be easier to construct those objects the normal
      Python way in the fmin function, and just stick them into the evaluation
      memo.  The experiment ctrl object itself is inserted using this technique.
      """
      for node in pyll.dfs(expr):
          try:
              if node.obj == lit:
                  memo[node] = obj
          except (AttributeError, ValueError) as e:
              # -- non-literal nodes don't have node.obj
              pass
      return memo
  
imports: import datetime
  import numpy
  import logging
  import os
  import shutil
  import sys
  import uuid
  import numpy
  from .None import pyll
  from contextlib import contextmanager
label_desc: Use image node_id 11 for calling a global function with example usage: use_obj_for_literal_in_memo(expr, obj, lit, memo) and returns: memo