code: def window_selector_config(flags_obj):
      """Creates a WindowSelectorOptions proto based on input and default settings.
  
      Args:
        flags_obj: configuration FLAGS.
  
      Returns:
        realigner_pb2.WindowSelector protobuf.
  
      Raises:
        ValueError: If either ws_{min,max}_supporting_reads are set and
          ws_use_window_selector_model is True.
          Or if ws_window_selector_model > ws_max_num_supporting_reads.
          Or if ws_use_window_selector_model is False and
          ws_window_selector_model is not None.
      """
      if not flags_obj.ws_use_window_selector_model:
          if flags_obj.ws_window_selector_model is not None:
              raise ValueError(
                  "Cannot specify a ws_window_selector_model "
                  "if ws_use_window_selector_model is False."
              )
  
          min_num_supporting_reads = (
              _DEFAULT_MIN_SUPPORTING_READS
              if flags_obj.ws_min_num_supporting_reads
              == _UNSET_WS_INT_FLAG
              else flags_obj.ws_min_num_supporting_reads
          )
          max_num_supporting_reads = (
              _DEFAULT_MAX_SUPPORTING_READS
              if flags_obj.ws_max_num_supporting_reads
              == _UNSET_WS_INT_FLAG
              else flags_obj.ws_max_num_supporting_reads
          )
          window_selector_model = realigner_pb2.WindowSelectorModel(
              model_type=realigner_pb2.WindowSelectorModel.VARIANT_READS,
              variant_reads_model=realigner_pb2.WindowSelectorModel.VariantReadsThresholdModel(
                  min_num_supporting_reads=min_num_supporting_reads,
                  max_num_supporting_reads=max_num_supporting_reads,
              ),
          )
      else:
          if (
              flags_obj.ws_min_num_supporting_reads
              != _UNSET_WS_INT_FLAG
          ):
              raise ValueError(
                  "Cannot use both ws_min_num_supporting_reads and "
                  "ws_use_window_selector_model flags."
              )
          if (
              flags_obj.ws_max_num_supporting_reads
              != _UNSET_WS_INT_FLAG
          ):
              raise ValueError(
                  "Cannot use both ws_max_num_supporting_reads and "
                  "ws_use_window_selector_model flags."
              )
  
          if flags_obj.ws_window_selector_model is None:
              window_selector_model = _ALLELE_COUNT_LINEAR_MODEL_DEFAULT
          else:
              with epath.Path(
                  flags_obj.ws_window_selector_model
              ).open() as f:
                  window_selector_model = text_format.Parse(
                      f.read(), realigner_pb2.WindowSelectorModel()
                  )
  
      if (
          window_selector_model.model_type
          == realigner_pb2.WindowSelectorModel.VARIANT_READS
      ):
          model = window_selector_model.variant_reads_model
          if (
              model.max_num_supporting_reads
              < model.min_num_supporting_reads
          ):
              raise ValueError(
                  "ws_min_supporting_reads should be smaller than "
                  "ws_max_supporting_reads."
              )
  
      keep_legacy_behavior = False
      if "keep_legacy_allele_counter_behavior" in flags_obj:
          keep_legacy_behavior = (
              flags_obj.keep_legacy_allele_counter_behavior
          )
      ws_config = realigner_pb2.WindowSelectorOptions(
          min_mapq=flags_obj.ws_min_mapq,
          min_base_quality=flags_obj.ws_min_base_quality,
          min_windows_distance=flags_obj.ws_min_windows_distance,
          max_window_size=flags_obj.ws_max_window_size,
          region_expansion_in_bp=flags_obj.ws_region_expansion_in_bp,
          window_selector_model=window_selector_model,
          keep_legacy_behavior=keep_legacy_behavior,
      )
  
      return ws_config
  
imports: import csv
  import os
  import os.path
  from absl import flags
  from etils import epath
  from deepvariant.protos import realigner_pb2
  from deepvariant.realigner import window_selector
  from deepvariant.realigner.python import debruijn_graph
  from deepvariant.realigner.python import fast_pass_aligner
  from deepvariant.vendor import timer
  from google.protobuf import text_format
  from third_party.nucleus.io import sam
  from third_party.nucleus.protos import cigar_pb2
  from third_party.nucleus.protos import reads_pb2
  from third_party.nucleus.util import cigar
  from third_party.nucleus.util import ranges
  from third_party.nucleus.util import utils
  from third_party.nucleus.util.cigar import READ_ADVANCING_OPS
  from third_party.nucleus.util.cigar import REF_ADVANCING_OPS
label_desc: Use image node_id 1 for calling a global function with example usage: window_selector_config(flags_obj) and returns: ws_config