code: def gather(ht, key, value, *fields) -> Table:
      """Collapse fields into key-value pairs.
  
      :func:`.gather` mimics the functionality of the `gather()` function found in R's
      ``tidyr`` package. This is a way to turn "wide" format data into "long"
      format data.
  
      Parameters
      ----------
      ht : :class:`.Table`
          A Hail table.
      key : :class:`str`
          The name of the key field in the gathered table.
      value : :class:`str`
          The name of the value field in the gathered table.
      fields : variable-length args of obj:`str`
          Names of fields to gather in ``ht``.
  
      Returns
      -------
      :class:`.Table`
          Table with original ``fields`` gathered into ``key`` and ``value`` fields.
      """
  
      ht = ht.annotate(
          _col_val=hl.array(
              [
                  hl.struct(field_name=field, value=ht[field])
                  for field in fields
              ]
          )
      )
      ht = ht.drop(*fields)
      ht = ht.explode(ht["_col_val"])
      ht = ht.annotate(
          **{key: ht["_col_val"][0], value: ht["_col_val"][1]}
      )
      ht = ht.drop("_col_val")
  
      ht_tmp = new_temp_file()
      ht.write(ht_tmp)
  
      return hl.read_table(ht_tmp)
  
imports: import hail
  from hail import Table
  from hail.typecheck import typecheck, nullable, oneof, sequenceof
  from hail.utils import wrap_to_list, new_temp_file
label_desc: Use image node_id 1 for calling a global function with example usage: gather(ht, key, value) and returns: hl