code: def grep(
      regex,
      path,
      max_count=100,
      *,
      show: bool = True,
      force: bool = False,
      force_bgz: bool = False,
  ):
      r"""Searches given paths for all lines containing regex matches.
  
      Examples
      --------
  
      Print all lines containing the string ``hello`` in *file.txt*:
  
      >>> hl.grep('hello','data/file.txt')
  
      Print all lines containing digits in *file1.txt* and *file2.txt*:
  
      >>> hl.grep('\\d', ['data/file1.txt','data/file2.txt'])
  
      Notes
      -----
      :func:`.grep` mimics the basic functionality of Unix ``grep`` in
      parallel, printing results to the screen. This command is provided as a
      convenience to those in the statistical genetics community who often
      search enormous text files like VCFs. Hail uses `Java regular expression
      patterns
      <https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html>`__.
      The `RegExr sandbox <http://regexr.com/>`__ may be helpful.
  
      Parameters
      ----------
      regex : :class:`str`
          The regular expression to match.
      path : :class:`str` or :obj:`list` of :obj:`str`
          The files to search.
      max_count : :obj:`int`
          The maximum number of matches to return
      show : :obj:`bool`
          When `True`, show the values on stdout. When `False`, return a
          dictionary mapping file names to lines.
      force_bgz : :obj:`bool`
          If ``True``, read files as blocked gzip files, assuming
          that they were actually compressed using the BGZ codec. This option is
          useful when the file extension is not ``'.bgz'``, but the file is
          blocked gzip, so that the file can be read in parallel and not on a
          single node.
      force : :obj:`bool`
          If ``True``, read gzipped files serially on one core. This should
          be used only when absolutely necessary, as processing time will be
          increased due to lack of parallelism.
  
      Returns
      ---
      :obj:`dict` of :class:`str` to :obj:`list` of :obj:`str`
      """
      from hail.backend.spark_backend import SparkBackend
  
      if isinstance(hl.current_backend(), SparkBackend):
          jfs = Env.spark_backend("grep").fs._jfs
          if show:
              Env.backend()._jhc.grepPrint(
                  jfs, regex, jindexed_seq_args(path), max_count
              )
              return
          else:
              jarr = Env.backend()._jhc.grepReturn(
                  jfs, regex, jindexed_seq_args(path), max_count
              )
              return {x._1(): list(x._2()) for x in jarr}
  
      ht = hl.import_lines(path, force=force, force_bgz=force_bgz)
      ht = ht.filter(ht.text.matches(regex))
      ht = ht.head(max_count)
      lines = ht.collect()
      if show:
          print(
              "\n".join(line.file + ": " + line.text for line in lines)
          )
          return
  
      results = defaultdict(list)
      for line in lines:
          results[line.file].append(line.text)
      return results
  
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 10 for calling a global function with example usage: grep(regex, path, max_count) and returns: results, unknown