code: def _from_structure(
      X, sample_weight=None, structure=None, pseudocount=0.0
  ):
      """Fits a set of distributions to data given the structure.
  
      Given the structure, create the distribution objects and fit their
      parameters to the given data. This does not perform structure learning.
  
  
      Parameters
      ----------
      X: list, tuple, numpy.ndarray, torch.Tensor, shape=(-1, self.d)
              A set of examples to evaluate.
  
      sample_weight: list, tuple, numpy.ndarray, torch.Tensor, or None
              A set of weights for the examples. This can be either of shape
              (-1, self.d) or a vector of shape (-1,). Default is ones.
  
      structure: tuple
              A tuple of tuples where the internal tuples indicate the parents of
              that variable.
  
      pseudocount: double
              A pseudocount to add to each count. Default is 0.
  
  
      Returns
      -------
      model: pomegranate.bayesian_network.BayesianNetwork
              The fit Bayesian network.
      """
  
      X = _check_parameter(
          _cast_as_tensor(X),
          "X",
          min_value=0,
          ndim=2,
          dtypes=(torch.int32, torch.int64),
      )
      sample_weight = _check_parameter(
          _cast_as_tensor(sample_weight), "X", min_value=0, ndim=1
      )
  
      n, d = X.shape
  
      if sample_weight is None:
          sample_weight = torch.ones(
              n, dtype=torch.float32, device=X.device
          )
  
      if structure is None:
          structure = tuple([tuple() for i in range(d)])
  
      model = BayesianNetwork()
      if X.device != model.device:
          model.to(X.device)
  
      d = len(structure)
      distributions = []
  
      for i, parents in enumerate(structure):
          if len(parents) == 0:
              d = Categorical()
              if d.device != X.device:
                  d.to(X.device)
  
              d.fit(X[:, i : i + 1], sample_weight=sample_weight)
          else:
              parents = parents + (i,)
              d = ConditionalCategorical()
              if d.device != X.device:
                  d.to(X.device)
  
              d.fit(
                  X[:, parents].unsqueeze(-1),
                  sample_weight=sample_weight,
              )
  
          distributions.append(d)
  
      return distributions
  
imports: import time
  import numpy
  import torch
  import itertools
  import networkx
  from ._utils import _cast_as_tensor
  from ._utils import _cast_as_parameter
  from ._utils import _update_parameter
  from ._utils import _check_parameter
  from ._utils import _reshape_weights
  from .distributions._distribution import Distribution
  from .distributions import Categorical
  from .distributions import JointCategorical
  from .distributions import ConditionalCategorical
  from .factor_graph import FactorGraph
label_desc: Use image node_id 1 for calling a global function with example usage: _from_structure(X, sample_weight, structure, pseudocount) and returns: distributions