class_docstr: Google Cloud Dataproc APIs.
  
  All the methods in the hook where project_id is used must be called with
  keyword arguments rather than positional.
class_docstr_tok: ["Google","Cloud","Dataproc","APIs",".","All","the","methods","in","the","hook","where","project_id","is","used","must","be","called","with","keyword","arguments","rather","than","positional","."]
docstr: Wait for a batch job to complete.
  
  After submission of a batch job, the operator waits for the job to
  complete. This hook is, however, useful in the case when Airflow is
  restarted or the task pid is killed for any reason. In this case, the
  creation would happen again, catching the raised AlreadyExists, and fail
  to this function for waiting on completion.
  
  :param batch_id: The batch ID.
  :param region: Cloud Dataproc region to handle the request.
  :param project_id: Google Cloud project ID that the cluster belongs to.
  :param wait_check_interval: The amount of time to pause between checks
      for job completion.
  :param retry: A retry object used to retry requests. If *None*, requests
      will not be retried.
  :param timeout: The amount of time, in seconds, to wait for the request
      to complete. If *retry* is specified, the timeout applies to each
      individual attempt.
  :param metadata: Additional metadata that is provided to the method.
code: def wait_for_batch(
      self,
      batch_id: str,
      region: str,
      project_id: str,
      wait_check_interval: int = 10,
      retry: AsyncRetry | _MethodDefault = DEFAULT,
      timeout: float | None = None,
      metadata: Sequence[tuple[str, str]] = (),
  ) -> Batch:
      """Wait for a batch job to complete.
  
      After submission of a batch job, the operator waits for the job to
      complete. This hook is, however, useful in the case when Airflow is
      restarted or the task pid is killed for any reason. In this case, the
      creation would happen again, catching the raised AlreadyExists, and fail
      to this function for waiting on completion.
  
      :param batch_id: The batch ID.
      :param region: Cloud Dataproc region to handle the request.
      :param project_id: Google Cloud project ID that the cluster belongs to.
      :param wait_check_interval: The amount of time to pause between checks
          for job completion.
      :param retry: A retry object used to retry requests. If *None*, requests
          will not be retried.
      :param timeout: The amount of time, in seconds, to wait for the request
          to complete. If *retry* is specified, the timeout applies to each
          individual attempt.
      :param metadata: Additional metadata that is provided to the method.
      """
      state = None
      first_loop: bool = True
      while state not in [
          Batch.State.CANCELLED,
          Batch.State.FAILED,
          Batch.State.SUCCEEDED,
          Batch.State.STATE_UNSPECIFIED,
      ]:
          try:
              if not first_loop:
                  time.sleep(wait_check_interval)
              first_loop = False
              self.log.debug("Waiting for batch %s", batch_id)
              result = self.get_batch(
                  batch_id=batch_id,
                  region=region,
                  project_id=project_id,
                  retry=retry,
                  timeout=timeout,
                  metadata=metadata,
              )
              state = result.state
          except ServerError as err:
              self.log.info(
                  "Retrying. Dataproc API returned server error when waiting for batch id %s: %s",
                  batch_id,
                  err,
              )
  
      return result
  
imports: from __future__ import annotations
  import time
  import uuid
  from typing import TYPE_CHECKING, Any, Sequence
  from google.api_core.client_options import ClientOptions
  from google.api_core.exceptions import ServerError
  from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
  from google.cloud.dataproc_v1 import Batch, BatchControllerAsyncClient, BatchControllerClient, Cluster, ClusterControllerAsyncClient, ClusterControllerClient, Job, JobControllerAsyncClient, JobControllerClient, JobStatus, WorkflowTemplate, WorkflowTemplateServiceAsyncClient, WorkflowTemplateServiceClient
  from airflow.exceptions import AirflowException
  from airflow.providers.google.common.consts import CLIENT_INFO
  from airflow.providers.google.common.hooks.base_google import GoogleBaseHook
  from airflow.version import version
label_desc: Use image node_id 25 for calling the DataprocHook obj's underlying member method code with example usage: obj.wait_for_batch(batch_id, region, project_id, wait_check_interval, retry, timeout, metadata) and returns: result