class_docstr: Generates a random graphs which can be used for testing or other purposes.
  
  The generated graph supports both node-level and graph-level labels.
  
  Example
  -------
  >>> from deepchem.utils.fake_data_generator import FakeGraphGenerator
  >>> fgg  = FakeGraphGenerator(min_nodes=8, max_nodes=10,  n_node_features=5, avg_degree=8, n_edge_features=3, n_classes=2, task='graph', z=5)
  >>> graphs = fgg.sample(n_graphs=10)
  >>> type(graphs)
  <class 'deepchem.data.datasets.NumpyDataset'>
  >>> type(graphs.X[0])
  <class 'deepchem.feat.graph_data.GraphData'>
  >>> len(graphs) == 10  # num_graphs
  True
  
  Note
  ----
  The FakeGraphGenerator class is based on torch_geometric.dataset.FakeDataset
  class.
docstr: Samples graphs
  
  Parameters
  ----------
  n_graphs: int, default 100
      Number of graphs to generate
  
  Returns
  -------
  graphs: NumpyDataset
      Generated Graphs
docstr_tok: ["Samples","graphs","Parameters","--","--","--","--","--","n_graphs",":","int",",","default","100","Number","of","graphs","to","generate","Returns","--","--","--","-","graphs",":","NumpyDataset","Generated","Graphs"]
code: def sample(self, n_graphs: int = 100) -> NumpyDataset:
      """Samples graphs
  
      Parameters
      ----------
      n_graphs: int, default 100
          Number of graphs to generate
  
      Returns
      -------
      graphs: NumpyDataset
          Generated Graphs
      """
      graphs, labels = [], []
      for i in range(n_graphs):
          n_nodes = random.randint(self.min_nodes, self.max_nodes)
          edge_index = generate_edge_index(n_nodes, self.avg_degree)
          n_edges = edge_index.shape[1]
  
          if self.task == "graph":
              graph_label = random.randint(0, self.n_classes - 1)
              node_features = (
                  np.random.rand(n_nodes, self.n_node_features)
                  + graph_label
              )
              edge_features = (
                  np.random.rand(n_edges, self.n_edge_features)
                  + graph_label
              )
              kwargs = {}
              for feature_name, feature_shape in self.kwargs.items():
                  kwargs[feature_name] = (
                      np.random.rand(1, feature_shape) + graph_label
                  )
              labels.append(graph_label)
  
          elif self.task == "node":
              node_label = np.random.randint(
                  0, self.n_classes - 1, n_nodes
              ).astype(np.float64)
              node_features = np.random.rand(
                  n_nodes, self.n_node_features
              ) + node_label.reshape(-1, 1)
              # For a node-prediction task, label is not added to edge features and other global features
              # because label here is a node-level attribute and not a graph-level attribute
              edge_features = np.random.rand(
                  n_edges, self.n_edge_features
              )
              kwargs = {}
              for feature_name, feature_shape in self.kwargs.items():
                  kwargs[feature_name] = np.random.rand(
                      1, feature_shape
                  )
              kwargs["y"] = node_label
  
          graph = GraphData(
              node_features, edge_index, edge_features, **kwargs
          )
          graphs.append(graph)
  
          if self.task == "graph":
              graph_dataset = NumpyDataset(
                  X=np.array(graphs), y=np.array(labels)
              )
          elif self.task == "node":
              # In this case, the 'y' attribute of GraphData will contain the
              # node-level labels.
              graph_dataset = NumpyDataset(X=np.array(graphs))
      return graph_dataset
  
file_path: deepchem/deepchem/utils/fake_data_generator.py
imports: import random
  import numpy
  from deepchem.data import NumpyDataset
  from deepchem.feat import GraphData
label_desc: Use image node_id 2 for calling the FakeGraphGenerator obj's underlying member method code with example usage: obj.sample(n_graphs) and returns: graph_dataset