code: def from_prev_calc(cls, prev_calc_dir, mode="gap",
                         reciprocal_density=50, copy_chgcar=True, **kwargs):
          
  
          vasprun, outcar = get_vasprun_outcar(prev_calc_dir)
  
          # note: don't standardize the cell because we want to retain k-points
          prev_structure = get_structure_from_prev_run(vasprun, outcar,
                                                       sym_prec=0)
  
          added_kpoints = []
  
          if mode.lower() == "gap":
              bs = vasprun.get_band_structure()
              vbm, cbm = bs.get_vbm()["kpoint"], bs.get_cbm()["kpoint"]
              if vbm:
                  added_kpoints.append(vbm.frac_coords)
              if cbm:
                  added_kpoints.append(cbm.frac_coords)
  
          files_to_transfer = {}
          if copy_chgcar:
              chgcars = sorted(glob.glob(str(Path(prev_calc_dir) / "CHGCAR*")))
              if chgcars:
                  files_to_transfer["CHGCAR"] = str(chgcars[-1])
  
          return cls(
              structure=prev_structure,
              added_kpoints=added_kpoints, reciprocal_density=reciprocal_density,
              mode=mode, files_to_transfer=files_to_transfer, **kwargs)
docs: Generate a set of Vasp input files for HSE calculations from a
          directory of previous Vasp run. if mode=="gap", it explicitly adds VBM
          and CBM of the prev run to the k-point list of this run.
  
          Args:
              prev_calc_dir (str): Directory containing the outputs
                  (vasprun.xml and OUTCAR) of previous vasp run.
              mode (str): Either "uniform", "gap" or "line"
              reciprocal_density (int): density of k-mesh
              copy_chgcar (bool): whether to copy CHGCAR of previous run
              \\*\\*kwargs: All kwargs supported by MPHSEBSStaticSet,
                  other than prev_structure which is determined from the previous
                  calc dir.