docstr: Initializes the DataHandler
  
  Parameters
  ----------
  model: tf.keras.Model
      Model instance.
  batch_size: int
      Batch size to use during training.
      May be overridden if `x` is ``GraphDataLoader`` or ``AbstractGraphPartitioner`` instance.
  dataset_type: string
      Dataset type that is being passed.
  epochs: int
      Number of epochs to train (default: 1)
  initial epoch: int
      Initial epoch number (default: 1)
  use_indexer: bool or Mapper
      Whether the data needs to be indexed or whether we need to use pre-defined indexer to map
      the data to index.
  use_filter: bool or dict
      Whether to use filter of not. If a dictionary is specified, the data in the dict is concatenated
      and used as filter.
  partitioning_k: int
      Number of partitions to create.
      May be overridden if `x` is an ``AbstractGraphPartitioner`` instance
docstr_tok: ["Initializes","the","DataHandler","Parameters","--","--","--","--","--","model",":","tf.keras.Model","Model","instance",".","batch_size",":","int","Batch","size","to","use","during","training",".","May","be","overridden","if","`","x","`","is","``","GraphDataLoader","``","or","``","AbstractGraphPartitioner","``","instance",".","dataset_type",":","string","Dataset","type","that","is","being","passed",".","epochs",":","int","Number","of","epochs","to","train","(","default",":","1",")","initial","epoch",":","int","Initial","epoch","number","(","default",":","1",")","use_indexer",":","bool","or","Mapper","Whether","the","data","needs","to","be","indexed","or","whether","we","need","to","use","pre-defined","indexer","to","map","the","data","to","index",".","use_filter",":","bool","or","dict","Whether","to","use","filter","of","not",".","If","a","dictionary","is","specified",",","the","data","in","the","dict","is","concatenated","and","used","as","filter",".","partitioning_k",":","int","Number","of","partitions","to","create",".","May","be","overridden","if","`","x","`","is","an","``","AbstractGraphPartitioner","``","instance"]
code: def __init__(
      self,
      x,
      model=None,
      batch_size=1,
      dataset_type="train",
      epochs=1,
      initial_epoch=0,
      use_indexer=True,
      use_filter=True,
      partitioning_k=1,
  ):
      """Initializes the DataHandler
  
      Parameters
      ----------
      model: tf.keras.Model
          Model instance.
      batch_size: int
          Batch size to use during training.
          May be overridden if `x` is ``GraphDataLoader`` or ``AbstractGraphPartitioner`` instance.
      dataset_type: string
          Dataset type that is being passed.
      epochs: int
          Number of epochs to train (default: 1)
      initial epoch: int
          Initial epoch number (default: 1)
      use_indexer: bool or Mapper
          Whether the data needs to be indexed or whether we need to use pre-defined indexer to map
          the data to index.
      use_filter: bool or dict
          Whether to use filter of not. If a dictionary is specified, the data in the dict is concatenated
          and used as filter.
      partitioning_k: int
          Number of partitions to create.
          May be overridden if `x` is an ``AbstractGraphPartitioner`` instance
      """
      self._initial_epoch = initial_epoch
      self._epochs = epochs
      self._model = model
      self._inferred_steps = None
      self.using_partitioning = False
  
      if partitioning_k <= 0:
          raise ValueError(
              "Incorrect value specified to partitioning_k"
          )
  
      if isinstance(x, GraphDataLoader):
          self._adapter = x
          self._parent_adapter = self._adapter
      elif isinstance(x, AbstractGraphPartitioner):
          self._parent_adapter = x._data
          self._adapter = x
          self.using_partitioning = True
          # override the partitioning_k value using partitioners k
          partitioning_k = x._k
      else:
          # use graph data loader by default
          self._adapter = GraphDataLoader(
              x,
              backend=NoBackend,
              batch_size=batch_size,
              dataset_type=dataset_type,
              use_indexer=use_indexer,
              use_filter=use_filter,
              in_memory=True,
          )
          self._parent_adapter = self._adapter
      if partitioning_k > 1:
          # if use partitioning then pass the graph data loader to partitioner and use
          # partitioned data manager
          assert (
              model is not None
          ), "Please pass the model to data_handler for partitioning!"
          self._adapter = get_partition_adapter(
              self._adapter,
              self._model,
              strategy="Bucket",
              partitioning_k=partitioning_k,
          )
  
          self.using_partitioning = True
  
file_path: AmpliGraph/ampligraph/datasets/data_adapter.py
imports: import contextlib
  import tqdm
  from tensorflow.python.framework import errors
  from .graph_data_loader import GraphDataLoader, NoBackend
  from .graph_partitioner import AbstractGraphPartitioner
  from .partitioned_data_manager import get_partition_adapter
label_desc: Use image node_id 1 to create a new DataHandler object  with example: obj = DataHandler(x, model, batch_size, dataset_type, epochs, initial_epoch, use_indexer, use_filter, partitioning_k)