code: def realigner_config(flags_obj):
      """Creates a RealignerOptions proto based on input and default settings.
  
      Args:
        flags_obj: configuration FLAGS.
  
      Returns:
        realigner_pb2.RealignerOptions protobuf.
  
      Raises:
        ValueError: If we observe invalid flag values.
      """
      ws_config = window_selector_config(flags_obj)
  
      dbg_config = realigner_pb2.DeBruijnGraphOptions(
          min_k=flags_obj.dbg_min_k,
          max_k=flags_obj.dbg_max_k,
          step_k=flags_obj.dbg_step_k,
          min_mapq=flags_obj.dbg_min_mapq,
          min_base_quality=flags_obj.dbg_min_base_quality,
          min_edge_weight=flags_obj.dbg_min_edge_weight,
          max_num_paths=flags_obj.dbg_max_num_paths,
      )
  
      aln_config = realigner_pb2.AlignerOptions(
          match=flags_obj.aln_match,
          mismatch=flags_obj.aln_mismatch,
          gap_open=flags_obj.aln_gap_open,
          gap_extend=flags_obj.aln_gap_extend,
          k=flags_obj.aln_k,
          error_rate=flags_obj.aln_error_rate,
          max_num_of_mismatches=flags_obj.max_num_mismatches,
          realignment_similarity_threshold=flags_obj.realignment_similarity_threshold,
          kmer_size=flags_obj.kmer_size,
          force_alignment=False,
      )
  
      diagnostics = realigner_pb2.Diagnostics(
          enabled=bool(flags_obj.realigner_diagnostics),
          output_root=flags_obj.realigner_diagnostics,
          emit_realigned_reads=flags_obj.emit_realigned_reads,
      )
  
      # The normalize_reads flag could came from the `flags_obj` arg, passed in
      # from make_examples_options.py. It is already part of AlleleCounterOptions in
      # MakeExamplesOptions. Here, we need to set it in RealignerOptions as well
      # because an if statement in fast_pass_aligner.cc needs it to decide whether
      # to run a specific logic.
      # This is not ideal. If there's a way to improve this, please do.
      normalize_reads = False
      if "normalize_reads" in flags_obj:
          normalize_reads = flags_obj.normalize_reads
      return realigner_pb2.RealignerOptions(
          ws_config=ws_config,
          dbg_config=dbg_config,
          aln_config=aln_config,
          diagnostics=diagnostics,
          split_skip_reads=flags_obj.split_skip_reads,
          normalize_reads=normalize_reads,
      )
  
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 2 for calling a global function with example usage: realigner_config(flags_obj) and returns: realigner_pb2