code: def random_state(state: RandomState | None = None):
      """
      Helper function for processing random_state arguments.
  
      Parameters
      ----------
      state : int, array-like, BitGenerator, Generator, np.random.RandomState, None.
          If receives an int, array-like, or BitGenerator, passes to
          np.random.RandomState() as seed.
          If receives an np.random RandomState or Generator, just returns that unchanged.
          If receives `None`, returns np.random.
          If receives anything else, raises an informative ValueError.
  
          Default None.
  
      Returns
      -------
      np.random.RandomState or np.random.Generator. If state is None, returns np.random
  
      """
      if is_integer(state) or isinstance(
          state, (np.ndarray, np.random.BitGenerator)
      ):
          return np.random.RandomState(state)
      elif isinstance(state, np.random.RandomState):
          return state
      elif isinstance(state, np.random.Generator):
          return state
      elif state is None:
          return np.random
      else:
          raise ValueError(
              "random_state must be an integer, array-like, a BitGenerator, Generator, "
              "a numpy RandomState, or None"
          )
  
imports: from __future__ import annotations
  import builtins
  from collections import abc, defaultdict
  from collections.abc import Collection, Generator, Hashable, Iterable, Sequence
  import contextlib
  from functools import partial
  import inspect
  from typing import TYPE_CHECKING, Any, Callable, TypeVar, cast, overload
  import warnings
  import numpy
  from pandas._libs import lib
  from pandas.compat.numpy import np_version_gte1p24
  from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike
  from pandas.core.dtypes.common import is_bool_dtype, is_integer
  from pandas.core.dtypes.generic import ABCExtensionArray, ABCIndex, ABCMultiIndex, ABCSeries
  from pandas.core.dtypes.inference import iterable_not_string
label_desc: Use image node_id 26 for calling a global function with example usage: random_state(state) and returns: np, state, state, np