code: def fromhdf5(hdf5_file, group=None, dataset=None, chunk_size=None):
      import h5py
  
      if isinstance(hdf5_file, h5py.Dataset):
          filename = hdf5_file.file.filename
          group = hdf5_file.parent.name
          dataset = hdf5_file.name.rsplit("/", 1)[1]
          chunk_size = (
              chunk_size if chunk_size is not None else hdf5_file.chunks
          )
          shape = hdf5_file.shape
          dtype = hdf5_file.dtype
      elif isinstance(hdf5_file, h5py.File):
          filename = hdf5_file.filename
          if dataset is None:
              raise ValueError("`dataset` should be provided")
          try:
              h5_dataset = hdf5_file[
                  TensorHDF5DataSource.get_path(group, dataset)
              ]
          except KeyError:
              raise ValueError(f"dataset({dataset}) does not exist")
          chunk_size = (
              chunk_size
              if chunk_size is not None
              else h5_dataset.chunks
          )
          shape = h5_dataset.shape
          dtype = h5_dataset.dtype
      elif isinstance(hdf5_file, str):
          filename = hdf5_file
          try:
              with h5py.File(open_file(filename), mode="r") as f:
                  if dataset is None:
                      raise ValueError("`dataset` should be provided")
                  h5_dataset = f[
                      TensorHDF5DataSource.get_path(group, dataset)
                  ]
  
                  chunk_size = (
                      chunk_size
                      if chunk_size is not None
                      else h5_dataset.chunks
                  )
                  shape = h5_dataset.shape
                  dtype = h5_dataset.dtype
          except KeyError:
              raise ValueError(f"dataset({dataset}) does not exist")
      else:
          raise TypeError(
              "`hdf5_file` passed has wrong type, "
              "expect str, h5py.File or h5py.Dataset, "
              f"got {type(hdf5_file)}"
          )
  
      op = TensorHDF5DataSource(
          filename=filename, group=group, dataset=dataset, dtype=dtype
      )
      return op(shape, chunk_size=chunk_size, order=TensorOrder.C_ORDER)
  
imports: from ...None import opcodes
  from ...lib.filesystem import open_file
  from .core import TensorFromHDF5Like, TensorOrder
label_desc: Use image node_id 1 for calling a global function with example usage: fromhdf5(hdf5_file, group, dataset, chunk_size) and returns: op