code: def init(
      sc=None,
      app_name=None,
      master=None,
      local="local[*]",
      log=None,
      quiet=False,
      append=False,
      min_block_size=0,
      branching_factor=50,
      tmp_dir=None,
      default_reference=None,
      idempotent=False,
      global_seed=None,
      spark_conf=None,
      skip_logging_configuration=False,
      local_tmpdir=None,
      _optimizer_iterations=None,
      *,
      backend=None,
      driver_cores=None,
      driver_memory=None,
      worker_cores=None,
      worker_memory=None,
      gcs_requester_pays_configuration: Optional[
          GCSRequesterPaysConfiguration
      ] = None,
      regions: Optional[List[str]] = None,
      gcs_bucket_allow_list: Optional[Dict[str, List[str]]] = None,
  ):
      """Initialize and configure Hail.
  
      This function will be called with default arguments if any Hail functionality is used. If you
      need custom configuration, you must explicitly call this function before using Hail. For
      example, to set the global random seed to 0, import Hail and immediately call
      :func:`.init`:
  
      >>> import hail as hl
      >>> hl.init(global_seed=0)  # doctest: +SKIP
  
      Hail has two backends, ``spark`` and ``batch``. Hail selects a backend by consulting, in order,
      these configuration locations:
  
      1. The ``backend`` parameter of this function.
      2. The ``HAIL_QUERY_BACKEND`` environment variable.
      3. The value of ``hailctl config get query/backend``.
  
      If no configuration is found, Hail will select the Spark backend.
  
      Examples
      --------
      Configure Hail to use the Batch backend:
  
      >>> import hail as hl
      >>> hl.init(backend='batch')  # doctest: +SKIP
  
      If a :class:`pyspark.SparkContext` is already running, then Hail must be
      initialized with it as an argument:
  
      >>> hl.init(sc=sc)  # doctest: +SKIP
  
      Configure Hail to bill to `my_project` when accessing any Google Cloud Storage bucket that has
      requester pays enabled:
  
      >>> hl.init(gcs_requester_pays_configuration='my-project')  # doctest: +SKIP
  
      Configure Hail to bill to `my_project` when accessing the Google Cloud Storage buckets named
      `bucket_of_fish` and `bucket_of_eels`:
  
      >>> hl.init(
      ...     gcs_requester_pays_configuration=('my-project', ['bucket_of_fish', 'bucket_of_eels'])
      ... )  # doctest: +SKIP
  
      You may also use `hailctl config set gcs_requester_pays/project` and `hailctl config set
      gcs_requester_pays/buckets` to achieve the same effect.
  
      See Also
      --------
      :func:`.stop`
  
      Parameters
      ----------
      sc : pyspark.SparkContext, optional
          Spark Backend only. Spark context. If not specified, the Spark backend will create a new
          Spark context.
      app_name : :class:`str`
          A name for this pipeline. In the Spark backend, this becomes the Spark application name. In
          the Batch backend, this is a prefix for the name of every Batch.
      master : :class:`str`, optional
          Spark Backend only. URL identifying the Spark leader (master) node or `local[N]` for local
          clusters.
      local : :class:`str`
          Spark Backend only. Local-mode core limit indicator. Must either be `local[N]` where N is a
          positive integer or `local[*]`. The latter indicates Spark should use all cores
          available. `local[*]` does not respect most containerization CPU limits. This option is only
          used if `master` is unset and `spark.master` is not set in the Spark configuration.
      log : :class:`str`
          Local path for Hail log file. Does not currently support distributed file systems like
          Google Storage, S3, or HDFS.
      quiet : :obj:`bool`
          Print fewer log messages.
      append : :obj:`bool`
          Append to the end of the log file.
      min_block_size : :obj:`int`
          Minimum file block size in MB.
      branching_factor : :obj:`int`
          Branching factor for tree aggregation.
      tmp_dir : :class:`str`, optional
          Networked temporary directory.  Must be a network-visible file
          path.  Defaults to /tmp in the default scheme.
      default_reference : :class:`str`
          *Deprecated*. Please use :func:`.default_reference` to set the default reference genome
  
          Default reference genome. Either ``'GRCh37'``, ``'GRCh38'``,
          ``'GRCm38'``, or ``'CanFam3'``.
      idempotent : :obj:`bool`
          If ``True``, calling this function is a no-op if Hail has already been initialized.
      global_seed : :obj:`int`, optional
          Global random seed.
      spark_conf : :obj:`dict` of :class:`str` to :class`str`, optional
          Spark backend only. Spark configuration parameters.
      skip_logging_configuration : :obj:`bool`
          Spark Backend only. Skip logging configuration in java and python.
      local_tmpdir : :class:`str`, optional
          Local temporary directory.  Used on driver and executor nodes.
          Must use the file scheme.  Defaults to TMPDIR, or /tmp.
      driver_cores : :class:`str` or :class:`int`, optional
          Batch backend only. Number of cores to use for the driver process. May be 1, 2, 4, or 8. Default is
          1.
      driver_memory : :class:`str`, optional
          Batch backend only. Memory tier to use for the driver process. May be standard or
          highmem. Default is standard.
      worker_cores : :class:`str` or :class:`int`, optional
          Batch backend only. Number of cores to use for the worker processes. May be 1, 2, 4, or 8. Default is
          1.
      worker_memory : :class:`str`, optional
          Batch backend only. Memory tier to use for the worker processes. May be standard or
          highmem. Default is standard.
      gcs_requester_pays_configuration : either :class:`str` or :class:`tuple` of :class:`str` and :class:`list` of :class:`str`, optional
          If a string is provided, configure the Google Cloud Storage file system to bill usage to the
          project identified by that string. If a tuple is provided, configure the Google Cloud
          Storage file system to bill usage to the specified project for buckets specified in the
          list. See examples above.
      regions : :obj:`list` of :class:`str`, optional
          List of regions to run jobs in when using the Batch backend. Use :data:`.ANY_REGION` to specify any region is allowed
          or use `None` to use the underlying default regions from the hailctl environment configuration. For example, use
          `hailctl config set batch/regions region1,region2` to set the default regions to use.
      gcs_bucket_allow_list:
          A list of buckets that Hail should be permitted to read from or write to, even if their default policy is to
          use "cold" storage. Should look like ``["bucket1", "bucket2"]``.
      """
      if Env._hc:
          if idempotent:
              return
          else:
              warning(
                  "Hail has already been initialized. If this call was intended to change configuration,"
                  " close the session with hl.stop() first."
              )
  
      if default_reference is not None:
          warnings.warn(
              "Using hl.init with a default_reference argument is deprecated. "
              "To set a default reference genome after initializing hail, "
              "call `hl.default_reference` with an argument to set the "
              "default reference genome."
          )
      else:
          default_reference = "GRCh37"
  
      backend = choose_backend(backend)
  
      if backend == "service":
          warnings.warn(
              'The "service" backend is now called the "batch" backend. Support for "service" will be removed in a '
              "future release."
          )
          backend = "batch"
  
      if backend == "batch":
          return hail_event_loop().run_until_complete(
              init_batch(
                  log=log,
                  quiet=quiet,
                  append=append,
                  tmpdir=tmp_dir,
                  local_tmpdir=local_tmpdir,
                  default_reference=default_reference,
                  global_seed=global_seed,
                  driver_cores=driver_cores,
                  driver_memory=driver_memory,
                  worker_cores=worker_cores,
                  worker_memory=worker_memory,
                  name_prefix=app_name,
                  gcs_requester_pays_configuration=gcs_requester_pays_configuration,
                  regions=regions,
                  gcs_bucket_allow_list=gcs_bucket_allow_list,
              )
          )
      if backend == "spark":
          return init_spark(
              sc=sc,
              app_name=app_name,
              master=master,
              local=local,
              min_block_size=min_block_size,
              branching_factor=branching_factor,
              spark_conf=spark_conf,
              _optimizer_iterations=_optimizer_iterations,
              log=log,
              quiet=quiet,
              append=append,
              tmp_dir=tmp_dir,
              local_tmpdir=local_tmpdir,
              default_reference=default_reference,
              global_seed=global_seed,
              skip_logging_configuration=skip_logging_configuration,
              gcs_requester_pays_configuration=gcs_requester_pays_configuration,
          )
      if backend == "local":
          return init_local(
              log=log,
              quiet=quiet,
              append=append,
              tmpdir=tmp_dir,
              default_reference=default_reference,
              global_seed=global_seed,
              skip_logging_configuration=skip_logging_configuration,
              gcs_requester_pays_configuration=gcs_requester_pays_configuration,
          )
      raise ValueError(f"unknown Hail Query backend: {backend}")
  
imports: from typing import Optional, Union, Tuple, Type, List, Dict
  from types import TracebackType
  import warnings
  import sys
  import os
  from contextlib import contextmanager
  from urllib.parse import urlparse, urlunparse
  from random import Random
  import pkg_resources
  from pyspark import SparkContext
  import hail
  from hail.genetics.reference_genome import ReferenceGenome, reference_genome_type
  from hail.typecheck import nullable, typecheck, typecheck_method, enumeration, dictof, oneof, sized_tupleof, sequenceof
  from hail.utils import get_env_or_default
  from hail.utils.java import Env, warning, choose_backend
  from hail.backend import Backend
  from hailtop.hail_event_loop import hail_event_loop
  from hailtop.utils import secret_alnum_string
  from hailtop.fs.fs import FS
  from hailtop.aiocloud.aiogoogle import GCSRequesterPaysConfiguration, get_gcs_requester_pays_configuration
  from .builtin_references import BUILTIN_REFERENCES
  from .backend.backend import local_jar_information
label_desc: Use image node_id 5 for calling a global function with example usage: init(sc, app_name, master, local, log, quiet, append, min_block_size, branching_factor, tmp_dir, default_reference, idempotent, global_seed, spark_conf, skip_logging_configuration, local_tmpdir, _optimizer_iterations) and returns: hail_event_loop, init_spark, init_local