code: def require_biallelic(
      dataset, method, tolerate_generic_locus: bool = False
  ) -> MatrixTable:
      if tolerate_generic_locus:
          require_row_key_variant_w_struct_locus(dataset, method)
      else:
          require_row_key_variant(dataset, method)
      return dataset._select_rows(
          method,
          hl.case()
          .when(dataset.alleles.length() == 2, dataset._rvrow)
          .or_error(
              f"'{method}' expects biallelic variants ('alleles' field of length 2), found "
              + hl.str(dataset.locus)
              + ", "
              + hl.str(dataset.alleles)
          ),
      )
  
imports: from typing import Union
  import hail
  from hail.expr import Expression, expr_numeric, expr_array, expr_interval, expr_any, construct_expr, construct_variable
  from hail.expr.types import tlocus, tarray, tstr, tstruct, ttuple
  from hail.matrixtable import MatrixTable
  from hail.table import Table
  from hail.typecheck import typecheck, nullable, func_spec, oneof
  from hail.utils import Interval, Struct, new_temp_file, deduplicate
  from hail.utils.misc import plural
  from hail.utils.java import Env, info
  from hail import ir
label_desc: Use image node_id 9 for calling a global function with example usage: require_biallelic(dataset, method, tolerate_generic_locus) and returns: dataset