class_docstr: Util class to build splits.
  
  Usage is as follow:
  
  ```py
  split_builder = SplitBuilder(...)
  
  with split_builder.maybe_beam_pipeline():
    split_info_future = split_builder.submit_split_generation(...)
  
  split_info = split_info_future.result()
  ```
  
  * submit_split_generation:
    * For generator based split: Generate the split
    * For Apache Beam based split: Create the `beam.PCollection` and returns
      a future.
  * `split_info_future.result()`: Called after all `beam.PCollection`s have
    finished. Finalize the `split_info` by collecting all pipeline results.
  
  `submit_split_generation` / `.result` should be called once per
  split.
class_docstr_tok: ["Util","class","to","build","splits",".","Usage","is","as","follow",":","``","`","py","split_builder","=","SplitBuilder","(","...",")","with","split_builder.maybe_beam_pipeline","(",")",":","split_info_future","=","split_builder.submit_split_generation","(","...",")","split_info","=","split_info_future.result","(",")","``","`","*","submit_split_generation",":","*","For","generator","based","split",":","Generate","the","split","*","For","Apache","Beam","based","split",":","Create","the","`","beam.PCollection","`","and","returns","a","future",".","*","`","split_info_future.result","(",")","`",":","Called","after","all","`","beam.PCollection","`","s","have","finished",".","Finalize","the","`","split_info","`","by","collecting","all","pipeline","results",".","`","submit_split_generation","`","\/","`",".result","`","should","be","called","once","per","split","."]
docstr: Instanciates and returns Apache Beam pipeline.
  
  Calling this function starts the Apache Beam mode.
  
  Returns:
    pipeline: The beam pipeline
docstr_tok: ["Instanciates","and","returns","Apache","Beam","pipeline",".","Calling","this","function","starts","the","Apache","Beam","mode",".","Returns",":","pipeline",":","The","beam","pipeline"]
code: def beam_pipeline(self) -> "beam.Pipeline":
      """Instanciates and returns Apache Beam pipeline.
  
      Calling this function starts the Apache Beam mode.
  
      Returns:
        pipeline: The beam pipeline
      """
      if not self._in_contextmanager:
          raise AssertionError(
              "beam_pipeline has to be created from within `SplitBuilder` "
              "contextmanager."
          )
  
      # On Colab, stderr isn't displayed by default, so using `print`.
      print_fn = print if utils.is_notebook() else logging.warning
      if not self._beam_runner and not self._beam_options:
          msg = utils.dedent(
              """
            **************************** WARNING *********************************
            Warning: The dataset you're trying to generate is using Apache Beam,
            yet no `beam_runner` nor `beam_options` was explicitly provided.
  
            Some Beam datasets take weeks to generate, so are usually not suited
            for single machine generation. Please have a look at the instructions
            to setup distributed generation:
  
            https://www.tensorflow.org/datasets/beam_datasets#generating_a_beam_dataset
            **********************************************************************
            """
          )
          print_fn(msg)
  
          total_memory = psutil.virtual_memory().total
          if self._dataset_size >= total_memory:
              if not click.confirm(
                  (
                      f"The dataset is {self._dataset_size} in size, but your machine"
                      f" has only {utils.Size(total_memory)} of memory. Continue?"
                  ),
                  default=True,
              ):
                  sys.exit(1)
  
      beam_options = (
          self._beam_options
          or beam.options.pipeline_options.PipelineOptions()
      )
      # Beam type checking assumes transforms multiple outputs are of same type,
      # which is not our case. Plus it doesn't handle correctly all types, so we
      # are better without it.
      beam_options.view_as(
          beam.options.pipeline_options.TypeOptions
      ).pipeline_type_check = False
      # Create the global pipeline object common for all splits
      pipeline = beam.Pipeline(
          runner=self._beam_runner, options=beam_options
      )
      self._beam_pipeline = pipeline.__enter__()
      return self._beam_pipeline
  
imports: import collections.abc
  import contextlib
  import dataclasses
  import functools
  import itertools
  import sys
  from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Tuple, Union
  from absl import logging
  import click
  import psutil
  from tensorflow_datasets.core import example_serializer
  from tensorflow_datasets.core import features
  from tensorflow_datasets.core import file_adapters
  from tensorflow_datasets.core import naming
  from tensorflow_datasets.core import splits
  from tensorflow_datasets.core import utils
  from tensorflow_datasets.core import writer
  from tensorflow_datasets.core.utils import shard_utils
  from tensorflow_datasets.core.utils.lazy_imports_utils import apache_beam
label_desc: Use image node_id 3 for calling the SplitBuilder obj's underlying member method code with example usage: obj.beam_pipeline() and returns: self