code: def import_vcf(
      path,
      force=False,
      force_bgz=False,
      header_file=None,
      min_partitions=None,
      drop_samples=False,
      call_fields=["PGT"],
      reference_genome="default",
      contig_recoding=None,
      array_elements_required=True,
      skip_invalid_loci=False,
      entry_float_type=tfloat64,
      filter=None,
      find_replace=None,
      n_partitions=None,
      block_size=None,
      _create_row_uids=False,
      _create_col_uids=False,
  ) -> MatrixTable:
      """Import VCF file(s) as a :class:`.MatrixTable`.
  
      Examples
      --------
  
      Import a standard bgzipped VCF with GRCh37 as the reference genome.
  
      >>> ds = hl.import_vcf('data/example2.vcf.bgz', reference_genome='GRCh37')
  
      Import a variant-partitioned dataset stored in one or more VCF files. The ``*`` is a glob
      pattern which matches any string of characters.
  
      >>> ds = hl.import_vcf('data/samplepart*.vcf')
  
      Import a VCF dataset and override every header with the header from ``data/samplepart1.vcf``. If
      the other VCF files are missing headers, have differing sample names, or otherwise have
      incompatible headers, `header_file` can be used to enforce a consistent header.
  
      >>> ds = hl.import_vcf('data/samplepart*.vcf', header_file='data/samplepart1.vcf')
  
      Import a VCF with GRCh38 as the reference genome that incorrectly uses the
      contig names from GRCh37 (i.e. uses contig name "1" instead of "chr1").
  
      >>> recode = {f"{i}":f"chr{i}" for i in (list(range(1, 23)) + ['X', 'Y'])}
      >>> ds = hl.import_vcf('data/grch38_bad_contig_names.vcf', reference_genome='GRCh38', contig_recoding=recode)
  
      Import a bgzipped VCF which uses the "gz" extension rather than the "bgz" extension:
  
      >>> ds = hl.import_vcf('data/sample.vcf.gz', force_bgz=True)
  
      Import a VCF which has missing values (".") inside INFO or FORMAT array fields:
  
      >>> print(open('data/missing-values-in-array-fields.vcf').read())
      ##fileformat=VCFv4.1
      ##FORMAT=<ID=GT,Number=1,Type=String,Description="Genotype">
      ##FORMAT=<ID=X,Number=.,Type=Integer,Description="">
      ##FORMAT=<ID=Y,Number=.,Type=Integer,Description="">
      ##FORMAT=<ID=Z,Number=.,Type=Integer,Description="">
      ##INFO=<ID=A,Number=A,Type=Integer,Description="">
      ##INFO=<ID=B,Number=R,Type=Float,Description="">
      ##INFO=<ID=C,Number=3,Type=Float,Description="">
      ##INFO=<ID=D,Number=.,Type=Float,Description="">
      #CHROM	POS	ID	REF	ALT	QUAL	FILTER	INFO	FORMAT	SAMPLE1
      1	123456	.	A	C	.	.	A=1,.;B=.,2,.;C=.	GT:X:Y:Z	0/0:1,.,1:.
  
      >>> ds = hl.import_vcf('data/missing-values-in-array-fields.vcf', array_elements_required=False)
      >>> ds.show(n_rows=1, n_cols=1, include_row_fields=True)
      +---------------+------------+------+-----------+----------+--------------+
      | locus         | alleles    | rsid |      qual | filters  | info.A       |
      +---------------+------------+------+-----------+----------+--------------+
      | locus<GRCh37> | array<str> | str  |   float64 | set<str> | array<int32> |
      +---------------+------------+------+-----------+----------+--------------+
      | 1:123456      | ["A","C"]  | NA   | -1.00e+01 | NA       | [1,NA]       |
      +---------------+------------+------+-----------+----------+--------------+
      <BLANKLINE>
      +------------------+----------------+----------------+--------------+
      | info.B           | info.C         | info.D         | 'SAMPLE1'.GT |
      +------------------+----------------+----------------+--------------+
      | array<float64>   | array<float64> | array<float64> | call         |
      +------------------+----------------+----------------+--------------+
      | [NA,2.00e+00,NA] | NA             | NA             | 0/0          |
      +------------------+----------------+----------------+--------------+
      <BLANKLINE>
      +--------------+--------------+--------------+
      | 'SAMPLE1'.X  | 'SAMPLE1'.Y  | 'SAMPLE1'.Z  |
      +--------------+--------------+--------------+
      | array<int32> | array<int32> | array<int32> |
      +--------------+--------------+--------------+
      | [1,NA,1]     | NA           | NA           |
      +--------------+--------------+--------------+
  
  
      Notes
      -----
  
      Hail is designed to be maximally compatible with files in the `VCF v4.2
      spec <https://samtools.github.io/hts-specs/VCFv4.2.pdf>`__.
  
      :func:`.import_vcf` takes a list of VCF files to load. All files must have
      the same header and the same set of samples in the same order (e.g., a
      dataset split by chromosome). Files can be specified as :ref:`Hadoop glob
      patterns <sec-hadoop-glob>`.
  
      Ensure that the VCF file is correctly prepared for import: VCFs should
      either be uncompressed (**.vcf**) or block compressed (**.vcf.bgz**). If you
      have a large compressed VCF that ends in **.vcf.gz**, it is likely that the
      file is actually block-compressed, and you should rename the file to
      **.vcf.bgz** accordingly. If you are unable to rename this file, please use
      `force_bgz=True` to ignore the extension and treat this file as
      block-gzipped.
  
      If you have a **non-block** (aka standard) gzipped file, you may use
      `force=True`; however, we strongly discourage this because each file will be
      processed by a single core. Import will take significantly longer for any
      non-trivial dataset.
  
      :func:`.import_vcf` does not perform deduplication - if the provided VCF(s)
      contain multiple records with the same chrom, pos, ref, alt, all these
      records will be imported as-is (in multiple rows) and will not be collapsed
      into a single variant.
  
      .. note::
  
          Using the **FILTER** field:
  
          The information in the FILTER field of a VCF is contained in the
          ``filters`` row field. This annotation is a ``set<str>`` and can be
          queried for filter membership with expressions like
          ``ds.filters.contains("VQSRTranche99.5...")``. Variants that are flagged
          as "PASS" will have no filters applied; for these variants,
          ``hl.len(ds.filters)`` is ``0``. Thus, filtering to PASS variants
          can be done with :meth:`.MatrixTable.filter_rows` as follows:
  
          >>> pass_ds = dataset.filter_rows(hl.len(dataset.filters) == 0)
  
      **Column Fields**
  
      - `s` (:py:data:`.tstr`) -- Column key. This is the sample ID.
  
      **Row Fields**
  
      - `locus` (:class:`.tlocus` or :class:`.tstruct`) -- Row key. The
        chromosome (CHROM field) and position (POS field). If `reference_genome`
        is defined, the type will be :class:`.tlocus` parameterized by
        `reference_genome`. Otherwise, the type will be a :class:`.tstruct` with
        two fields: `contig` with type :py:data:`.tstr` and `position` with type
        :py:data:`.tint32`.
      - `alleles` (:class:`.tarray` of :py:data:`.tstr`) -- Row key. An array
        containing the alleles of the variant. The reference allele (REF field) is
        the first element in the array and the alternate alleles (ALT field) are
        the subsequent elements.
      - `filters` (:class:`.tset` of :py:data:`.tstr`) -- Set containing all filters applied to a
        variant.
      - `rsid` (:py:data:`.tstr`) -- rsID of the variant.
      - `qual` (:py:data:`.tfloat64`) -- Floating-point number in the QUAL field.
      - `info` (:class:`.tstruct`) -- All INFO fields defined in the VCF header
        can be found in the struct `info`. Data types match the type specified
        in the VCF header, and if the declared ``Number`` is not 1, the result
        will be stored as an array.
  
      **Entry Fields**
  
      :func:`.import_vcf` generates an entry field for each FORMAT field declared
      in the VCF header. The types of these fields are generated according to the
      same rules as INFO fields, with one difference -- "GT" and other fields
      specified in `call_fields` will be read as :py:data:`.tcall`.
  
      Parameters
      ----------
      path : :class:`str` or :obj:`list` of :obj:`str`
          One or more paths to VCF files to read. Each path may or may not include glob expressions
          like ``*``, ``?``, or ``[abc123]``.
      force : :obj:`bool`
          If ``True``, load **.vcf.gz** files serially. No downstream operations
          can be parallelized, so this mode is strongly discouraged.
      force_bgz : :obj:`bool`
          If ``True``, load **.vcf.gz** files as blocked gzip files, assuming that they were actually
          compressed using the BGZ codec.
      header_file : :class:`str`, optional
          Optional header override file. If not specified, the first file in
          `path` is used. Glob patterns are not allowed in the `header_file`.
      min_partitions : :obj:`int`, optional
          Minimum partitions to load per file.
      drop_samples : :obj:`bool`
          If ``True``, create sites-only dataset. Don't load sample IDs or
          entries.
      call_fields : :obj:`list` of :class:`str`
          List of FORMAT fields to load as :py:data:`.tcall`. "GT" is
          loaded as a call automatically.
      reference_genome: :class:`str` or :class:`.ReferenceGenome`, optional
          Reference genome to use.
      contig_recoding: :obj:`dict` of (:class:`str`, :obj:`str`), optional
          Mapping from contig name in VCF to contig name in loaded dataset.
          All contigs must be present in the `reference_genome`, so this is
          useful for mapping differently-formatted data onto known references.
      array_elements_required : :obj:`bool`
          If ``True``, all elements in an array field must be present. Set this
          parameter to ``False`` for Hail to allow array fields with missing
          values such as ``1,.,5``. In this case, the second element will be
          missing. However, in the case of a single missing element ``.``, the
          entire field will be missing and **not** an array with one missing
          element.
      skip_invalid_loci : :obj:`bool`
          If ``True``, skip loci that are not consistent with `reference_genome`.
      entry_float_type: :class:`.HailType`
          Type of floating point entries in matrix table. Must be one of:
          :py:data:`.tfloat32` or :py:data:`.tfloat64`. Default:
          :py:data:`.tfloat64`.
      filter : :class:`str`, optional
          Line filter regex. A partial match results in the line being removed
          from the file. Applies before `find_replace`, if both are defined.
      find_replace : (:class:`str`, :obj:`str`)
          Line substitution regex. Functions like ``re.sub``, but obeys the exact
          semantics of Java's
          `String.replaceAll <https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#replaceAll-java.lang.String-java.lang.String->`__.
      n_partitions : :obj:`int`, optional
          Number of partitions.  If both `n_partitions` and `block_size`
          are specified, `n_partitions` will be used.
      block_size : :obj:`int`, optional
          Block size, in MB.  Default: 128MB blocks.
  
      Returns
      -------
      :class:`.MatrixTable`
  
      """
      if force:
          hl.utils.warning(
              f"You are trying to read {path} with *ONE* core of parallelism. This "
              "will be very slow. If this file is block-gzipped (bgzip-ed), use "
              "force_bgz=True instead."
          )
  
      reader = ir.MatrixVCFReader(
          path,
          call_fields,
          entry_float_type,
          header_file,
          n_partitions,
          block_size,
          min_partitions,
          reference_genome,
          contig_recoding,
          array_elements_required,
          skip_invalid_loci,
          force_bgz,
          force,
          filter,
          find_replace,
      )
      return MatrixTable(
          ir.MatrixRead(
              reader,
              drop_cols=drop_samples,
              drop_row_uids=not _create_row_uids,
              drop_col_uids=not _create_col_uids,
          )
      )
  
imports: import os
  import re
  from collections import defaultdict
  import avro.schema
  from avro.datafile import DataFileReader
  from avro.io import DatumReader
  import hail
  from hail import ir
  from hail.expr import StructExpression, LocusExpression, expr_array, expr_float64, expr_str, expr_numeric, expr_call, expr_bool, expr_int32, to_expr, analyze
  from hail.expr.types import hail_type, tarray, tfloat64, tstr, tint32, tstruct, tcall, tbool, tint64, tfloat32
  from hail.genetics.reference_genome import reference_genome_type
  from hail.ir.utils import parse_type
  from hail.matrixtable import MatrixTable
  from hail.methods.misc import require_biallelic, require_row_key_variant, require_col_key_str
  from hail.table import Table
  from hail.typecheck import typecheck, nullable, oneof, dictof, anytype, sequenceof, enumeration, sized_tupleof, numeric, table_key_type, char
  from hail.utils import new_temp_file
  from hail.utils.deduplicate import deduplicate
  from hail.utils.java import Env, FatalError, jindexed_seq_args, warning
  from hail.utils.java import info
  from hail.utils.misc import wrap_to_list, plural
  from .import_lines_helpers import split_lines, should_remove_line
label_desc: Use image node_id 19 for calling a global function with example usage: import_vcf(path, force, force_bgz, header_file, min_partitions, drop_samples, call_fields, reference_genome, contig_recoding, array_elements_required, skip_invalid_loci, entry_float_type, filter, find_replace, n_partitions, block_size, _create_row_uids, _create_col_uids) and returns: MatrixTable