code: def tohdf5(hdf5_file, x, group=None, dataset=None, **kwds):
      import h5py
  
      x = astensor(x)
      if isinstance(hdf5_file, h5py.Dataset):
          filename = hdf5_file.file.filename
          group = hdf5_file.parent.name
          dataset = hdf5_file.name.rsplit("/", 1)[1]
      elif isinstance(hdf5_file, h5py.File):
          filename = hdf5_file.filename
          if dataset is None:
              raise ValueError("`dataset` should be provided")
      elif isinstance(hdf5_file, str):
          filename = hdf5_file
          if dataset is None:
              raise ValueError("`dataset` should be provided")
      else:
          raise TypeError(
              "`hdf5_file` passed has wrong type, "
              "expect str, h5py.File or h5py.Dataset, "
              f"got {type(hdf5_file)}"
          )
  
      op = TensorHDF5DataStore(
          filename=filename,
          group=group,
          dataset=dataset,
          dataset_kwds=kwds,
      )
      return op(x)
  
imports: import threading
  import time
  from typing import List
  import numpy
  from ...None import opcodes
  from ...core.context import get_context
  from ...oscar import ActorNotExist
  from ...serialization.serializables import FieldTypes, KeyField, StringField, DictField, TupleField
  from ...lib.filesystem import open_file
  from ...utils import has_unknown_shape
  from ..datasource import tensor
  from .core import TensorDataStore
label_desc: Use image node_id 1 for calling a global function with example usage: tohdf5(hdf5_file, x, group, dataset) and returns: op