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.
code: def __init__(
      self,
      mean,
      covariance_matrix,
      validate_args=False,
      interleaved=True,
  ):
      if not torch.is_tensor(mean) and not isinstance(
          mean, LinearOperator
      ):
          raise RuntimeError(
              "The mean of a MultitaskMultivariateNormal must be a Tensor or LinearOperator"
          )
  
      if not torch.is_tensor(covariance_matrix) and not isinstance(
          covariance_matrix, LinearOperator
      ):
          raise RuntimeError(
              "The covariance of a MultitaskMultivariateNormal must be a Tensor or LinearOperator"
          )
  
      if mean.dim() < 2:
          raise RuntimeError(
              "mean should be a matrix or a batch matrix (batch mode)"
          )
  
      # Ensure that shapes are broadcasted appropriately across the mean and covariance
      # Means can have singleton dimensions for either the `n` or `t` dimensions
      batch_shape = torch.broadcast_shapes(
          mean.shape[:-2], covariance_matrix.shape[:-2]
      )
      if mean.shape[-2:].numel() != covariance_matrix.size(-1):
          if covariance_matrix.size(-1) % mean.shape[-2:].numel():
              raise RuntimeError(
                  f"mean shape {mean.shape} is incompatible with covariance shape {covariance_matrix.shape}"
              )
          elif mean.size(-2) == 1:
              mean = mean.expand(
                  *batch_shape,
                  covariance_matrix.size(-1) // mean.size(-1),
                  mean.size(-1),
              )
          elif mean.size(-1) == 1:
              mean = mean.expand(
                  *batch_shape,
                  mean.size(-2),
                  covariance_matrix.size(-2) // mean.size(-2),
              )
          else:
              raise RuntimeError(
                  f"mean shape {mean.shape} is incompatible with covariance shape {covariance_matrix.shape}"
              )
      else:
          mean = mean.expand(*batch_shape, *mean.shape[-2:])
  
      self._output_shape = mean.shape
      # TODO: Instead of transpose / view operations, use a PermutationLinearOperator (see #539)
      # to handle interleaving
      self._interleaved = interleaved
      if self._interleaved:
          mean_mvn = mean.reshape(*mean.shape[:-2], -1)
      else:
          mean_mvn = mean.transpose(-1, -2).reshape(
              *mean.shape[:-2], -1
          )
      super().__init__(
          mean=mean_mvn,
          covariance_matrix=covariance_matrix,
          validate_args=validate_args,
      )
  
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 1 to create a new MultitaskMultivariateNormal object from inherited base classes: MultivariateNormal with example: obj = MultitaskMultivariateNormal(mean, covariance_matrix, validate_args, interleaved)