class_docstr: Batch GraphData class
  
  Attributes
  ----------
  node_features: np.ndarray
      Concatenated node feature matrix with shape [num_nodes, num_node_features].
      `num_nodes` is total number of nodes in the batch graph.
  edge_index: np.ndarray, dtype int
      Concatenated graph connectivity in COO format with shape [2, num_edges].
      `num_edges` is total number of edges in the batch graph.
  edge_features: np.ndarray, optional (default None)
      Concatenated edge feature matrix with shape [num_edges, num_edge_features].
      `num_edges` is total number of edges in the batch graph.
  node_pos_features: np.ndarray, optional (default None)
      Concatenated node position matrix with shape [num_nodes, num_dimensions].
      `num_nodes` is total number of edges in the batch graph.
  num_nodes: int
      The number of nodes in the batch graph.
  num_node_features: int
      The number of features per node in the graph.
  num_edges: int
      The number of edges in the batch graph.
  num_edges_features: int, optional (default None)
      The number of features per edge in the graph.
  graph_index: np.ndarray, dtype int
      This vector indicates which graph the node belongs with shape [num_nodes,].
  
  Examples
  --------
  >>> import numpy as np
  >>> from deepchem.feat.graph_data import GraphData
  >>> node_features_list = np.random.rand(2, 5, 10)
  >>> edge_index_list = np.array([
  ...    [[0, 1, 2, 3, 4], [1, 2, 3, 4, 0]],
  ...    [[0, 1, 2, 3, 4], [1, 2, 3, 4, 0]],
  ... ], dtype=int)
  >>> user_defined_attribute = np.array([0, 1])
  >>> graph_list = [GraphData(node_features, edge_index, attribute=user_defined_attribute)
  ...     for node_features, edge_index in zip(node_features_list, edge_index_list)]
  >>> batch_graph = BatchGraphData(graph_list=graph_list)
class_docstr_tok: ["Batch","GraphData","class","Attributes","--","--","--","--","--","node_features",":","np.ndarray","Concatenated","node","feature","matrix","with","shape","[","num_nodes",",","num_node_features","]",".","`","num_nodes","`","is","total","number","of","nodes","in","the","batch","graph",".","edge_index",":","np.ndarray",",","dtype","int","Concatenated","graph","connectivity","in","COO","format","with","shape","[","2",",","num_edges","]",".","`","num_edges","`","is","total","number","of","edges","in","the","batch","graph",".","edge_features",":","np.ndarray",",","optional","(","default","None",")","Concatenated","edge","feature","matrix","with","shape","[","num_edges",",","num_edge_features","]",".","`","num_edges","`","is","total","number","of","edges","in","the","batch","graph",".","node_pos_features",":","np.ndarray",",","optional","(","default","None",")","Concatenated","node","position","matrix","with","shape","[","num_nodes",",","num_dimensions","]",".","`","num_nodes","`","is","total","number","of","edges","in","the","batch","graph",".","num_nodes",":","int","The","number","of","nodes","in","the","batch","graph",".","num_node_features",":","int","The","number","of","features","per","node","in","the","graph",".","num_edges",":","int","The","number","of","edges","in","the","batch","graph",".","num_edges_features",":","int",",","optional","(","default","None",")","The","number","of","features","per","edge","in","the","graph",".","graph_index",":","np.ndarray",",","dtype","int","This","vector","indicates","which","graph","the","node","belongs","with","shape","[","num_nodes",",","]",".","Examples","--","--","--","--",">",">",">","import","numpy","as","np",">",">",">","from","deepchem.feat.graph_data","import","GraphData",">",">",">","node_features_list","=","np.random.rand","(","2",",","5",",","10",")",">",">",">","edge_index_list","=","np.array","(","[","...","[","[","0",",","1",",","2",",","3",",","4","]",",","[","1",",","2",",","3",",","4",",","0","]","]",",","...","[","[","0",",","1",",","2",",","3",",","4","]",",","[","1",",","2",",","3",",","4",",","0","]","]",",","...","]",",","dtype=int",")",">",">",">","user_defined_attribute","=","np.array","(","[","0",",","1","]",")",">",">",">","graph_list","=","[","GraphData","(","node_features",",","edge_index",",","attribute=user_defined_attribute",")","...","for","node_features",",","edge_index","in","zip","(","node_features_list",",","edge_index_list",")","]",">",">",">","batch_graph","=","BatchGraphData","(","graph_list=graph_list",")"]
docstr: Convert numpy arrays to torch tensors for BatchGraphData. BatchGraphData is very similar to GraphData, but it combines all graphs into a single graph object and it has an additional attribute `graph_index` which indicates which nodes belong to which graph.
  
  Parameters
  ----------
  device : str
      Device to store the tensors. Default to 'cpu'.
  
  Example
  -------
  >>> num_nodes, num_node_features = 5, 32
  >>> num_edges, num_edge_features = 6, 32
  >>> node_features = np.random.random_sample((num_nodes, num_node_features))
  >>> edge_features = np.random.random_sample((num_edges, num_edge_features))
  >>> edge_index = np.random.randint(0, num_nodes, (2, num_edges))
  >>> graph_data = GraphData(node_features, edge_index, edge_features)
  >>> node_features2 = np.random.random_sample((num_nodes, num_node_features))
  >>> edge_features2 = np.random.random_sample((num_edges, num_edge_features))
  >>> edge_index2 = np.random.randint(0, num_nodes, (2, num_edges))
  >>> graph_data2 = GraphData(node_features2, edge_index2, edge_features2)
  >>> batch_graph_data = BatchGraphData([graph_data, graph_data2])
  >>> batch_graph_data = batch_graph_data.numpy_to_torch()
  >>> print(type(batch_graph_data.node_features))
  <class 'torch.Tensor'>
docstr_tok: ["Convert","numpy","arrays","to","torch","tensors","for","BatchGraphData",".","BatchGraphData","is","very","similar","to","GraphData",",","but","it","combines","all","graphs","into","a","single","graph","object","and","it","has","an","additional","attribute","`","graph_index","`","which","indicates","which","nodes","belong","to","which","graph",".","Parameters","--","--","--","--","--","device",":","str","Device","to","store","the","tensors",".","Default","to","'cpu","'",".","Example","--","--","--","-",">",">",">","num_nodes",",","num_node_features","=","5",",","32",">",">",">","num_edges",",","num_edge_features","=","6",",","32",">",">",">","node_features","=","np.random.random_sample","(","(","num_nodes",",","num_node_features",")",")",">",">",">","edge_features","=","np.random.random_sample","(","(","num_edges",",","num_edge_features",")",")",">",">",">","edge_index","=","np.random.randint","(","0",",","num_nodes",",","(","2",",","num_edges",")",")",">",">",">","graph_data","=","GraphData","(","node_features",",","edge_index",",","edge_features",")",">",">",">","node_features2","=","np.random.random_sample","(","(","num_nodes",",","num_node_features",")",")",">",">",">","edge_features2","=","np.random.random_sample","(","(","num_edges",",","num_edge_features",")",")",">",">",">","edge_index2","=","np.random.randint","(","0",",","num_nodes",",","(","2",",","num_edges",")",")",">",">",">","graph_data2","=","GraphData","(","node_features2",",","edge_index2",",","edge_features2",")",">",">",">","batch_graph_data","=","BatchGraphData","(","[","graph_data",",","graph_data2","]",")",">",">",">","batch_graph_data","=","batch_graph_data.numpy_to_torch","(",")",">",">",">","print","(","type","(","batch_graph_data.node_features",")",")","<","class","'torch.Tensor","'",">"]
code: def numpy_to_torch(self, device: str = "cpu"):
      """
      Convert numpy arrays to torch tensors for BatchGraphData. BatchGraphData is very similar to GraphData, but it combines all graphs into a single graph object and it has an additional attribute `graph_index` which indicates which nodes belong to which graph.
  
      Parameters
      ----------
      device : str
          Device to store the tensors. Default to 'cpu'.
  
      Example
      -------
      >>> num_nodes, num_node_features = 5, 32
      >>> num_edges, num_edge_features = 6, 32
      >>> node_features = np.random.random_sample((num_nodes, num_node_features))
      >>> edge_features = np.random.random_sample((num_edges, num_edge_features))
      >>> edge_index = np.random.randint(0, num_nodes, (2, num_edges))
      >>> graph_data = GraphData(node_features, edge_index, edge_features)
      >>> node_features2 = np.random.random_sample((num_nodes, num_node_features))
      >>> edge_features2 = np.random.random_sample((num_edges, num_edge_features))
      >>> edge_index2 = np.random.randint(0, num_nodes, (2, num_edges))
      >>> graph_data2 = GraphData(node_features2, edge_index2, edge_features2)
      >>> batch_graph_data = BatchGraphData([graph_data, graph_data2])
      >>> batch_graph_data = batch_graph_data.numpy_to_torch()
      >>> print(type(batch_graph_data.node_features))
      <class 'torch.Tensor'>
      """
      import torch
  
      graph_copy = super().numpy_to_torch(device)
  
      graph_index = (
          torch.from_numpy(self.graph_index)
          .long()
          .to(device)  # type: ignore
      )
      graph_copy.graph_index = graph_index
  
      return graph_copy
  
file_path: deepchem/deepchem/feat/graph_data.py
imports: from typing import Optional, Sequence
  import numpy
label_desc: Use image node_id 3 for calling the BatchGraphData obj's underlying member method code with example usage: obj.numpy_to_torch(device) and returns: graph_copy