def METHOD_NAME(
    package_type: str,
    packages_source_type: str,
    packages_source: str,
    distro_name,
    remote_machine_type,
    package_builder_name,
    other_cmd_args: List[str],
):
    use_aio_package = is_builder_creates_aio_package(
        package_builder_name=package_builder_name
    )
    dependencies_builder_cls = remote_test_dependency_builders[package_builder_name]
    if use_aio_package:
        arch = dependencies_builder_cls.PACKAGE_BUILDER.ARCHITECTURE
    else:
        arch = CpuArch.x86_64
    dependencies_builder = dependencies_builder_cls(
        package_type=package_type,
        packages_source_type=packages_source_type,
        packages_source=packages_source,
        package_builder_name=package_builder_name,
    )
    dependencies_builder.build()
    distro = DISTROS[distro_name]
    packages_root_tarball = dependencies_builder.result_dir / PACKAGES_ROOT_TARBALL_NAME
    in_docker_packages_root_tarball = f"/tmp/{PACKAGES_ROOT_TARBALL_NAME}"
    command = [
        "tests/end_to_end_tests/managed_packages_tests/remote_machine_tests",
        "--builder-name",
        package_builder_name,
        "--package-type",
        package_type,
        "--distro-name",
        distro_name,
        "--remote-machine-type",
        remote_machine_type,
        "--packages-source-type",
        "repo-tarball",
        "--packages-source",
        in_docker_packages_root_tarball,
        *other_cmd_args,
    ]
    try:
        if remote_machine_type == "ec2":
            run_tests_in_ec2(
                ec2_image=distro.ec2_images[arch],
                ec2_instance_size_id=distro.ec2_instance_size_id,
                command=command,
                pytest_runner_path=dependencies_builder.portable_pytest_runner_path,
                source_tarball_path=dependencies_builder.agent_source_tarball_path,
                file_mappings={
                    packages_root_tarball: in_docker_packages_root_tarball,
                },
            )
        else:
            run_test_in_docker(
                docker_image=distro.docker_image,
                command=command,
                architecture=arch,
                pytest_runner_path=dependencies_builder.portable_pytest_runner_path,
                source_tarball_path=dependencies_builder.agent_source_tarball_path,
                file_mappings={
                    packages_root_tarball: in_docker_packages_root_tarball,
                },
            )
    except Exception as e:
        logger.error(f"Remote test failed. Error: {str(e)}")
        raise