class_docstr: Constructs a multi-output multivariate Normal random variable, based on mean and covariance
  Can be multi-output multivariate, or a batch of multi-output multivariate Normal
  
  Passing a matrix mean corresponds to a multi-output multivariate Normal
  Passing a matrix mean corresponds to a batch of multivariate Normals
  
  :param torch.Tensor mean:  An `n x t` or batch `b x n x t` matrix of means for the MVN distribution.
  :param ~linear_operator.operators.LinearOperator covar: An `... x NT x NT` (batch) matrix.
      covariance matrix of MVN distribution.
  :param bool validate_args: (default=False) If True, validate `mean` and `covariance_matrix` arguments.
  :param bool interleaved: (default=True) If True, covariance matrix is interpreted as block-diagonal w.r.t.
      inter-task covariances for each observation. If False, it is interpreted as block-diagonal
      w.r.t. inter-observation covariance for each task.
docstr: Reinterprate a batch of multivariate normal distributions as an (independent) multitask multivariate normal
  distribution.
  
  :param ~gpytorch.distributions.MultivariateNormal batch_mvn: The base MVN distribution.
      (This distribution should have at least one batch dimension).
  :param int task_dim: Which batch dimension should be interpreted as the dimension for the independent tasks.
  :returns: the independent multitask distribution
  :rtype: gpytorch.distributions.MultitaskMultivariateNormal
  
  Example:
      >>> # model is a gpytorch.models.VariationalGP
      >>> # likelihood is a gpytorch.likelihoods.Likelihood
      >>> mean = torch.randn(4, 2, 3)
      >>> covar_factor = torch.randn(4, 2, 3, 3)
      >>> covar = covar_factor @ covar_factor.transpose(-1, -2)
      >>> mvn = gpytorch.distributions.MultivariateNormal(mean, covar)
      >>> print(mvn.event_shape, mvn.batch_shape)
      >>> # torch.Size([3]), torch.Size([4, 2])
      >>>
      >>> mmvn = MultitaskMultivariateNormal.from_batch_mvn(mvn, task_dim=-1)
      >>> print(mmvn.event_shape, mmvn.batch_shape)
      >>> # torch.Size([3, 2]), torch.Size([4])
docstr_tok: ["Reinterprate","a","batch","of","multivariate","normal","distributions","as","an","(","independent",")","multitask","multivariate","normal","distribution",".",":","param","~gpytorch.distributions.MultivariateNormal","batch_mvn",":","The","base","MVN","distribution",".","(","This","distribution","should","have","at","least","one","batch","dimension",")",".",":","param","int","task_dim",":","Which","batch","dimension","should","be","interpreted","as","the","dimension","for","the","independent","tasks",".",":","returns",":","the","independent","multitask","distribution",":","rtype",":","gpytorch.distributions.MultitaskMultivariateNormal","Example",":",">",">",">","#","model","is","a","gpytorch.models.VariationalGP",">",">",">","#","likelihood","is","a","gpytorch.likelihoods.Likelihood",">",">",">","mean","=","torch.randn","(","4",",","2",",","3",")",">",">",">","covar_factor","=","torch.randn","(","4",",","2",",","3",",","3",")",">",">",">","covar","=","covar_factor","@","covar_factor.transpose","(","-1",",","-2",")",">",">",">","mvn","=","gpytorch.distributions.MultivariateNormal","(","mean",",","covar",")",">",">",">","print","(","mvn.event_shape",",","mvn.batch_shape",")",">",">",">","#","torch.Size","(","[","3","]",")",",","torch.Size","(","[","4",",","2","]",")",">",">",">",">",">",">","mmvn","=","MultitaskMultivariateNormal.from_batch_mvn","(","mvn",",","task_dim=-1",")",">",">",">","print","(","mmvn.event_shape",",","mmvn.batch_shape",")",">",">",">","#","torch.Size","(","[","3",",","2","]",")",",","torch.Size","(","[","4","]",")"]
code: def from_batch_mvn(cls, batch_mvn, task_dim=-1):
      """
      Reinterprate a batch of multivariate normal distributions as an (independent) multitask multivariate normal
      distribution.
  
      :param ~gpytorch.distributions.MultivariateNormal batch_mvn: The base MVN distribution.
          (This distribution should have at least one batch dimension).
      :param int task_dim: Which batch dimension should be interpreted as the dimension for the independent tasks.
      :returns: the independent multitask distribution
      :rtype: gpytorch.distributions.MultitaskMultivariateNormal
  
      Example:
          >>> # model is a gpytorch.models.VariationalGP
          >>> # likelihood is a gpytorch.likelihoods.Likelihood
          >>> mean = torch.randn(4, 2, 3)
          >>> covar_factor = torch.randn(4, 2, 3, 3)
          >>> covar = covar_factor @ covar_factor.transpose(-1, -2)
          >>> mvn = gpytorch.distributions.MultivariateNormal(mean, covar)
          >>> print(mvn.event_shape, mvn.batch_shape)
          >>> # torch.Size([3]), torch.Size([4, 2])
          >>>
          >>> mmvn = MultitaskMultivariateNormal.from_batch_mvn(mvn, task_dim=-1)
          >>> print(mmvn.event_shape, mmvn.batch_shape)
          >>> # torch.Size([3, 2]), torch.Size([4])
      """
      orig_task_dim = task_dim
      task_dim = (
          task_dim
          if task_dim >= 0
          else (len(batch_mvn.batch_shape) + task_dim)
      )
      if task_dim < 0 or task_dim > len(batch_mvn.batch_shape):
          raise ValueError(
              f"task_dim of {orig_task_dim} is incompatible with MVN batch shape of {batch_mvn.batch_shape}"
          )
  
      num_dim = batch_mvn.mean.dim()
      res = cls(
          mean=batch_mvn.mean.permute(
              *range(0, task_dim),
              *range(task_dim + 1, num_dim),
              task_dim,
          ),
          covariance_matrix=BlockInterleavedLinearOperator(
              batch_mvn.lazy_covariance_matrix, block_dim=task_dim
          ),
      )
      return res
  
imports: import torch
  from linear_operator import LinearOperator, to_linear_operator
  from linear_operator.operators import BlockDiagLinearOperator, BlockInterleavedLinearOperator, CatLinearOperator, DiagLinearOperator
  from .multivariate_normal import MultivariateNormal
label_desc: Use image node_id 4 for calling the MultitaskMultivariateNormal obj's underlying member method code with example usage: obj.from_batch_mvn(cls, batch_mvn, task_dim) and returns: res