code: def rwlocked(call, read=None, write=None):
      import sys
  
      from dvc.dependency.db import AbstractDependency
      from dvc.dependency.repo import RepoDependency
      from dvc.rwlock import rwlock
  
      if read is None:
          read = []
  
      if write is None:
          write = []
  
      stage = call._args[0]
  
      assert stage.repo.lock.is_locked
  
      def _chain(names):
          return [
              item.fs_path
              for attr in names
              for item in getattr(stage, attr)
              # There is no need to lock RepoDependency deps, as there is no
              # corresponding OutputREPO, so we can't even write it.
              if not isinstance(
                  item, (RepoDependency, AbstractDependency)
              )
          ]
  
      cmd = " ".join(sys.argv)
  
      with rwlock(
          stage.repo.tmp_dir,
          stage.repo.fs,
          cmd,
          _chain(read),
          _chain(write),
          stage.repo.config["core"].get("hardlink_lock", False),
      ):
          return call()
  
imports: from functools import wraps
  from funcy import decorator
label_desc: Use image node_id 1 for calling a global function with example usage: rwlocked(call, read, write) and returns: unknown, call