def METHOD_NAME(plugin_name: str, state: str) -> DynamicRemoteOptions:
    # NB: If we use the same file name for multiple runs, import loading might be memoized. So
    # we use a distinct file name.
    plugin_path = tmp_path / plugin_name / "register.py"
    safe_mkdir_for(plugin_path)
    plugin_path.touch()
    plugin_path.write_text(
        dedent(
            f"""\
            from pants.option.global_options import AuthPluginState, AuthPluginResult
            def remote_auth(initial_execution_headers, initial_store_headers, options, **kwargs):
                return AuthPluginResult(
                    state=AuthPluginState.{state},
                    execution_headers={{
                        **{{k: "baz" for k in initial_execution_headers}},
                        "exec": "xyz",
                    }},
                    store_headers={{
                        **{{k: "baz" for k in initial_store_headers}},
                        "store": "abc",
                        "store_url": options.for_global_scope().remote_store_address,
                    }},
                    instance_name="custom_instance",
                    store_address="grpc://custom_store",
                    execution_address="grpc://custom_exec",
                )
            """
        )
    )
    sys.path.append(tmp_path.as_posix())
    result = create_dynamic_remote_options(
        initial_headers={"foo": "bar"},
        plugin=plugin_name,
    )
    sys.path.pop()
    return result