class_docstr: Hook for Apache Livy through the REST API.
  
  :param livy_conn_id: reference to a pre-defined Livy Connection.
  :param extra_options: A dictionary of options passed to Livy.
  :param extra_headers: A dictionary of headers passed to the HTTP request to livy.
  :param auth_type: The auth type for the service.
  
  .. seealso::
      For more details refer to the Apache Livy API reference:
      https://livy.apache.org/docs/latest/rest-api.html
class_docstr_tok: ["Hook","for","Apache","Livy","through","the","REST","API",".",":","param","livy_conn_id",":","reference","to","a","pre-defined","Livy","Connection",".",":","param","extra_options",":","A","dictionary","of","options","passed","to","Livy",".",":","param","extra_headers",":","A","dictionary","of","headers","passed","to","the","HTTP","request","to","livy",".",":","param","auth_type",":","The","auth","type","for","the","service",".","..","seealso",":",":","For","more","details","refer","to","the","Apache","Livy","API","reference",":","https",":","\/\/livy.apache.org\/docs\/latest\/rest-api.html"]
docstr: Fetch the state of the specified batch.
  
  :param session_id: identifier of the batch sessions
  :param retry_args: Arguments which define the retry behaviour.
      See Tenacity documentation at https://github.com/jd/tenacity
  :return: batch state
docstr_tok: ["Fetch","the","state","of","the","specified","batch",".",":","param","session_id",":","identifier","of","the","batch","sessions",":","param","retry_args",":","Arguments","which","define","the","retry","behaviour",".","See","Tenacity","documentation","at","https",":","\/\/github.com\/jd\/tenacity",":","return",":","batch","state"]
code: def get_batch_state(
      self,
      session_id: int | str,
      retry_args: dict[str, Any] | None = None,
  ) -> BatchState:
      """
      Fetch the state of the specified batch.
  
      :param session_id: identifier of the batch sessions
      :param retry_args: Arguments which define the retry behaviour.
          See Tenacity documentation at https://github.com/jd/tenacity
      :return: batch state
      """
      self._validate_session_id(session_id)
  
      self.log.debug("Fetching info for batch session %s", session_id)
      response = self.run_method(
          endpoint=f"/batches/{session_id}/state",
          retry_args=retry_args,
          headers=self.extra_headers,
      )
  
      try:
          response.raise_for_status()
      except requests.exceptions.HTTPError as err:
          self.log.warning(
              "Got status code %d for session %s",
              err.response.status_code,
              session_id,
          )
          raise AirflowException(
              f"Unable to fetch batch with id: {session_id}. Message: {err.response.text}"
          )
  
      jresp = response.json()
      if "state" not in jresp:
          raise AirflowException(
              f"Unable to get state for batch with id: {session_id}"
          )
      return BatchState(jresp["state"])
  
imports: from __future__ import annotations
  import asyncio
  import json
  import re
  from enum import Enum
  from typing import TYPE_CHECKING, Any, Sequence
  import aiohttp
  import requests
  from aiohttp import ClientResponseError
  from asgiref.sync import sync_to_async
  from airflow.exceptions import AirflowException
  from airflow.providers.http.hooks.http import HttpAsyncHook, HttpHook
  from airflow.utils.log.logging_mixin import LoggingMixin
label_desc: Use image node_id 6 for calling the LivyHook obj's underlying member method code with example usage: obj.get_batch_state(session_id, retry_args) and returns: BatchState