class_docstr: parallel.Execution is a tool for writing easy threading-based parallel tests.
  
  Execution.run is the main helper function, but there are a few magic getters that return
  correct thread-specific values when called from within an Execution.run-wrapped function.
  
  Example usage:
  
      SIZE = 10
      with parallel.Execution(SIZE) as pex:
          @pex.run
          def all_ranks():
              return pex.rank
  
          assert all_ranks == list(range(SIZE))
class_docstr_tok: ["parallel.Execution","is","a","tool","for","writing","easy","threading-based","parallel","tests",".","Execution.run","is","the","main","helper","function",",","but","there","are","a","few","magic","getters","that","return","correct","thread-specific","values","when","called","from","within","an","Execution.run-wrapped","function",".","Example","usage",":","SIZE","=","10","with","parallel.Execution","(","SIZE",")","as","pex",":","@","pex.run","def","all_ranks","(",")",":","return","pex.rank","assert","all_ranks","==","list","(","range","(","SIZE",")",")"]
code: def local_rank(self) -> int:
      thread_id = threading.get_ident()
      assert (
          thread_id in self._info
      ), "must be called from within an @Execute-decorated function"
      return self._info[thread_id][2]
  
file_path: determined/harness/tests/parallel.py
imports: import contextlib
  import itertools
  import sys
  import threading
  import traceback
  from typing import Any, Callable, Dict, Iterator, List, Tuple, TypeVar
  import pytest
  from determined import core
label_desc: Use image node_id 7 for calling the Execution obj's underlying member method code with example usage: obj.local_rank() and returns: self