code: def make_nd_diag(F, x: Tensor, d: int) -> Tensor:
      """
      Make a diagonal tensor, given the diagonal.
  
      Parameters
      ----------
      F
          The function space to use.
      x
          Diagonal to use, shape :math:`(..., d)`.
      d
          Last dimension of `x`.
  
      Returns
      -------
      Tensor
          A tensor y of shape :math:`(..., d, d)` such that
          :math:`y[..., i, i] = x[..., i]`.
      """
      return F.broadcast_mul(F.eye(d), x.expand_dims(axis=-1))
  
imports: import inspect
  import tempfile
  from pathlib import Path
  from typing import List, Optional, Tuple, cast, Type
  import mxnet
  from mxnet.gluon.block import _flatten
  from gluonts.core.serde import dump_json, load_json
  from gluonts.mx import Tensor
label_desc: Use image node_id 11 for calling a global function with example usage: make_nd_diag(F, x, d) and returns: F