code: def read_10x_mtx(path, var_names='gene_symbols', make_unique=True, cache=False, gex_only=True) -> AnnData:
      
      path = Path(path)
      genefile_exists = (path / 'genes.tsv').is_file()
      read = _read_legacy_10x_mtx if genefile_exists else _read_v3_10x_mtx
      adata = read(
          str(path),
          var_names=var_names,
          make_unique=make_unique,
          cache=cache,
      )
      if genefile_exists or not gex_only:
          return adata
      else:
          gex_rows = list(map(lambda x: x == 'Gene Expression', adata.var['feature_types']))
          return adata[:, gex_rows]
docs: Read 10x-Genomics-formatted mtx directory.
  
      Parameters
      ----------
      path : `str`
          Path to directory for `.mtx` and `.tsv` files,
          e.g. './filtered_gene_bc_matrices/hg19/'.
      var_names : {'gene_symbols', 'gene_ids'}, optional (default: 'gene_symbols')
          The variables index.
      make_unique : `bool`, optional (default: `True`)
          Whether to make the variables index unique by appending '-1',
          '-2' etc. or not.
      cache : `bool`, optional (default: `False`)
          If `False`, read from source, if `True`, read from fast 'h5ad' cache.
      gex_only : `bool`, optional (default: `True`)
          Only keep 'Gene Expression' data and ignore other feature types,
          e.g. 'Antibody Capture', 'CRISPR Guide Capture', or 'Custom'
  
      Returns
      -------
      An :class:`~anndata.AnnData` object