class_docstr: Base class for Datasets.
docstr: Open existing dataset or create a new one at ``filepath``.
  
  Args:
      filepath: Path to dataset file
      mode: File handling mode. Possible values are "w-" (create, fail if file
          exists), "w" (create, overwrite existing), "a" (append existing,
          create if doesn't exist), "r" (read existing, must exist), and "copy",
          which loads the dataset into memory and detaches it from the underlying
          file. Default is "r".
  Returns:
      Dataset object from file
docstr_tok: ["Open","existing","dataset","or","create","a","new","one","at","``","filepath","``",".","Args",":","filepath",":","Path","to","dataset","file","mode",":","File","handling","mode",".","Possible","values","are","``","w-","''","(","create",",","fail","if","file","exists",")",",","``","w","''","(","create",",","overwrite","existing",")",",","``","a","''","(","append","existing",",","create","if","does","n't","exist",")",",","``","r","''","(","read","existing",",","must","exist",")",",","and","``","copy","''",",","which","loads","the","dataset","into","memory","and","detaches","it","from","the","underlying","file",".","Default","is","``","r","''",".","Returns",":","Dataset","object","from","file"]
code: def open(
      cls,
      filepath: Union[str, Path],
      mode: Literal["w", "w-", "a", "r", "copy"] = "r",
  ) -> "Dataset":
      """Open existing dataset or create a new one at ``filepath``.
  
      Args:
          filepath: Path to dataset file
          mode: File handling mode. Possible values are "w-" (create, fail if file
              exists), "w" (create, overwrite existing), "a" (append existing,
              create if doesn't exist), "r" (read existing, must exist), and "copy",
              which loads the dataset into memory and detaches it from the underlying
              file. Default is "r".
      Returns:
          Dataset object from file
      """
      filepath = Path(filepath).expanduser()
  
      if mode == "copy":
          with h5py.File(filepath, "r") as f_to_copy:
              f = hdf5.create_group()
              hdf5.copy_all(f_to_copy, f)
      else:
          f = h5py.File(filepath, mode)
  
      return cls(f)
  
imports: import typing
  from dataclasses import dataclass
  from pathlib import Path
  from types import MappingProxyType
  from typing import Any, ClassVar, Generic, List, Literal, Optional, Tuple, Type, TypeVar, Union, cast, get_origin
  from typing_extensions import dataclass_transform
  from pennylane.data.base import hdf5
  from pennylane.data.base.attribute import AttributeInfo, DatasetAttribute
  from pennylane.data.base.hdf5 import HDF5Any, HDF5Group, h5py
  from pennylane.data.base.mapper import MapperMixin, match_obj_type
  from pennylane.data.base.typing_util import UNSET, T
label_desc: Use image node_id 2 for calling the Dataset obj's underlying member method code with example usage: obj.open(cls, filepath, mode) and returns: cls