code: def _lock(filename):
      try:
          return _locks[filename]
      except KeyError:
          _locks[filename] = FileLock(filename + ".lock")
      return _locks[filename]
  
imports: from contextlib import contextmanager
  import shelve
  from filelock import FileLock
label_desc: Use image node_id 1 for calling a global function with example usage: _lock(filename) and returns: _locks, _locks