docs: def marginalize(self, variables, inplace=True):
          """
          Marginalize the factor with respect to the given variables.
  
          Parameters
          ----------
          variables: list, array-like
              List of variables with respect to which factor is to be maximized.
  
          inplace: boolean
              If inplace=True it will modify the factor itself, else would return
              a new ContinuousFactor instance.
  
          Returns
          -------
          DiscreteFactor or None: if inplace=True (default) returns None
                          if inplace=False returns a new ContinuousFactor instance.
  
          Examples
          --------
          >>> from pgmpy.factors.continuous import ContinuousFactor
          >>> from scipy.stats import multivariate_normal
          >>> std_normal_pdf = lambda *x: multivariate_normal.pdf(x, [0, 0], [[1, 0], [0, 1]])
          >>> std_normal = ContinuousFactor(['x1', 'x2'], std_normal_pdf)
          >>> std_normal.scope()
          ['x1', 'x2']
          >>> std_normal.assignment([1, 1])
          0.058549831524319168
          >>> std_normal.marginalize(['x2'])
          >>> std_normal.scope()
          ['x1']
          >>> std_normal.assignment(1)
  
          """
          phi = self if inplace else self.copy()
          phi.distribution = phi.distribution.marginalize(variables, inplace=False)
  
          if not inplace:
              return phi