code: def get_mx_ndarray(
      ctx, in_tensor, dtype, initializer, attach_grad=True
  ):
      """Helper function to prepare a MXNet NDArray tensor in given Context (ctx) of type (dtype) with given
      initializer. You can get a new Tensor by providing only "Shape" or "Numpy NDArray" or another MXNet NDArray as
      "in_tensor".
  
      NOTE: This is a sync call and waits for the Tensor to be created.
  
      Parameters
      ----------
      ctx: mx.ctx, default mx.cpu()
          Context of the new MXNet NDArray Tensor.
      in_tensor: Numpy NDArray or MXNet NDArray or Tuple of shape
          Can be a tuple of shape or Numpy NDArray or MXNet NDArray.
      dtype: str
          Precision or Dtype of the expected Tensor. Ex: "float32", "Int64"
      initializer:
          Function reference to the initialize to use. Ex: mx.nd.random.normal, mx.nd.zeros
      attach_grad: Boolean, default True
          To attach a gradient for the Tensor. Default is True.
  
      Returns
      -------
      MXNet NDArray Tensor.
      """
      if isinstance(in_tensor, int) or isinstance(in_tensor, float):
          return in_tensor
  
      if isinstance(in_tensor, tuple):
          tensor = initializer(ctx=ctx, shape=in_tensor, dtype=dtype)
      elif isinstance(in_tensor, list):
          tensor = nd.array(in_tensor, ctx=ctx, dtype=dtype)
      elif isinstance(in_tensor, np.ndarray):
          tensor = nd.array(in_tensor)
      elif isinstance(in_tensor, mx.np.ndarray):
          tensor = in_tensor.as_nd_ndarray()
      elif isinstance(in_tensor, nd.NDArray):
          tensor = in_tensor.as_in_context(ctx)
      else:
          raise ValueError(
              "Invalid input type for creating input tensor. Input can be tuple() of shape or Numpy Array or"
              " MXNet NDArray. Given - ",
              in_tensor,
          )
  
      if attach_grad:
          tensor.attach_grad()
  
      tensor.wait_to_read()
      return tensor
  
imports: import numpy
  import mxnet
  import mxnet.ndarray
label_desc: Use image node_id 3 for calling a global function with example usage: get_mx_ndarray(ctx, in_tensor, dtype, initializer, attach_grad) and returns: tensor, in_tensor