# Path: xmanager/xm/job_blocks.py
# class SequentialArgs:
#   class _RegularItem:
#   class _KeywordItem:
# class ExecutableSpec(abc.ABC):
# class Executable(abc.ABC):
# class ExecutorSpec(abc.ABC):
# class Executor(abc.ABC):
# class Packageable:
# class Constraint(abc.ABC):
# class Job:
# class JobGroup:
#   def __init__(self) -> None:
#   def _ingest_regular_item(self, value: Any) -> None:
#   def _ingest_keyword_item(self, name: str, value: Any) -> None:
#   def _merge_from(self, args: 'SequentialArgs') -> None:
#     def import_regular_item(item: SequentialArgs._RegularItem):
#     def import_keyword_item(item: SequentialArgs._KeywordItem):
#   def from_collection(collection: Optional[UserArgs]) -> 'SequentialArgs':
#     def check_for_string(args: str) -> None:
#     def import_sequential_args(args: SequentialArgs) -> None:
#     def import_mapping(collection: Mapping[Any, Any]) -> None:
#     def import_sequence(collection: Sequence[Any]) -> None:
#   def to_list(
#       self,
#       escaper: Callable[[Any], str],
#       kwargs_joiner: Callable[[str, str], str] = utils.trivial_kwargs_joiner
#   ) -> List[str]:
#     def export_regular_item(item: SequentialArgs._RegularItem) -> str:
#     def export_keyword_item(item: SequentialArgs._KeywordItem) -> str:
#   def to_dict(self, kwargs_only: bool = False) -> Dict[str, Any]:
#     def export_regular_item(
#         item: SequentialArgs._RegularItem) -> Tuple[str, Any]:
#     def export_keyword_item(
#         item: SequentialArgs._KeywordItem) -> Tuple[str, Any]:
#   def __eq__(self, other) -> bool:
#   def __repr__(self) -> str:
# def merge_args(*operands: Union[SequentialArgs, UserArgs]) -> SequentialArgs:
#   def name(self) -> str:
#   def Spec(cls) -> ExecutorSpec:  # pylint: disable=invalid-name
#   def __init__(self,
#                *,
#                constraints: Optional[Sequence[Constraint]] = None,
#                **jobs: JobType) -> None:


import asyncio
import concurrent.futures as concurrent_futures
import threading
from typing import Awaitable, Callable, Sequence
from xmanager.xm import job_blocks
    """Adds new packageable to the batch."""
    with self._lock:
      future = concurrent_futures.Future()
      self._packageables.append(packageable)
      self._futures.append(future)

    def check_is_packaged() -> None:
      with self._lock:
        if packageable in self._packageables:
          raise PackageHasNotBeenCalledError(
              '.package() must be called before awaiting on the packaging '
              'result')

    async def package_impl() -> job_blocks.Executable:
      check_is_packaged()
      return await asyncio.wrap_future(future)

    class PicklablePackageImpl:

      def __await__(self):
        return package_impl().__await__()

      def __reduce__(self):
        check_is_packaged()
        return (_return_executable, (future.result(),))

    return PicklablePackageImpl()

  def package(
      self, extra_packageables: Sequence[job_blocks.Packageable] = ()

# Path: xmanager/xm/job_blocks.py
# class SequentialArgs:
#   class _RegularItem:
#   class _KeywordItem:
# class ExecutableSpec(abc.ABC):
# class Executable(abc.ABC):
# class ExecutorSpec(abc.ABC):
# class Executor(abc.ABC):
# class Packageable:
# class Constraint(abc.ABC):
# class Job:
# class JobGroup:
#   def __init__(self) -> None:
#   def _ingest_regular_item(self, value: Any) -> None:
#   def _ingest_keyword_item(self, name: str, value: Any) -> None:
#   def _merge_from(self, args: 'SequentialArgs') -> None:
#     def import_regular_item(item: SequentialArgs._RegularItem):
#     def import_keyword_item(item: SequentialArgs._KeywordItem):
#   def from_collection(collection: Optional[UserArgs]) -> 'SequentialArgs':
#     def check_for_string(args: str) -> None:
#     def import_sequential_args(args: SequentialArgs) -> None:
#     def import_mapping(collection: Mapping[Any, Any]) -> None:
#     def import_sequence(collection: Sequence[Any]) -> None:
#   def to_list(
#       self,
#       escaper: Callable[[Any], str],
#       kwargs_joiner: Callable[[str, str], str] = utils.trivial_kwargs_joiner
#   ) -> List[str]:
#     def export_regular_item(item: SequentialArgs._RegularItem) -> str:
#     def export_keyword_item(item: SequentialArgs._KeywordItem) -> str:
#   def to_dict(self, kwargs_only: bool = False) -> Dict[str, Any]:
#     def export_regular_item(
#         item: SequentialArgs._RegularItem) -> Tuple[str, Any]:
#     def export_keyword_item(
#         item: SequentialArgs._KeywordItem) -> Tuple[str, Any]:
#   def __eq__(self, other) -> bool:
#   def __repr__(self) -> str:
# def merge_args(*operands: Union[SequentialArgs, UserArgs]) -> SequentialArgs:
#   def name(self) -> str:
#   def Spec(cls) -> ExecutorSpec:  # pylint: disable=invalid-name
#   def __init__(self,
#                *,
#                constraints: Optional[Sequence[Constraint]] = None,
#                **jobs: JobType) -> None:


# Path: xmanager/xm/async_packager.py
import asyncio
import concurrent.futures as concurrent_futures
import threading
from typing import Awaitable, Callable, Sequence
from xmanager.xm import job_blocks

    """Adds new packageable to the batch."""
    with self._lock:
      future = concurrent_futures.Future()
      self._packageables.append(packageable)
      self._futures.append(future)

    def check_is_packaged() -> None:
      with self._lock:
        if packageable in self._packageables:
          raise PackageHasNotBeenCalledError(
              '.package() must be called before awaiting on the packaging '
              'result')

    async def package_impl() -> job_blocks.Executable:
      check_is_packaged()
      return await asyncio.wrap_future(future)

    class PicklablePackageImpl:

      def __await__(self):
        return package_impl().__await__()

      def __reduce__(self):
        check_is_packaged()
        return (_return_executable, (future.result(),))

    return PicklablePackageImpl()

  def package(
      self, extra_packageables: Sequence[job_blocks.Packageable] = ()

  ) -> Sequence[job_blocks.Executable]: