code: def test_optimizer_with_np_ndarrays():
      class LinearRegression(gluon.HybridBlock):
          def __init__(
              self,
              num_input_dim=0,
              num_hidden_dim=100,
              num_output_dim=10,
          ):
              super(LinearRegression, self).__init__()
              self.w1 = gluon.Parameter(
                  "w1",
                  shape=(num_input_dim, num_hidden_dim),
                  allow_deferred_init=True,
              )
              self.w2 = gluon.Parameter(
                  "w2",
                  shape=(num_hidden_dim, num_output_dim),
                  allow_deferred_init=True,
              )
  
          def forward(self, x):
              device = x.device
              h = x.dot(
                  self.w1.data(device)
              )  # equivalent to np.dot(x, w1)
              h_relu = npx.relu(
                  h
              )  # equivalent to npx.relu(h) but generating np.ndarray
              y_pred = h_relu.dot(
                  self.w2.data(device)
              )  # equivalent to np.dot(h_relu, w2)
              return y_pred
  
          def infer_shape(self, x, *args):
              pre_shape = self.w1.shape
              self.w1.shape = (x.shape[x.ndim - 1], pre_shape[1])
  
      class TotalLoss(gluon.HybridBlock):
          def forward(self, pred, label):
              return (
                  (pred - label) ** 2
              ).sum()  # equivalent to np.sum(np.square(pred - label))
  
      regressor = LinearRegression()
      regressor.initialize(mx.init.Uniform())
      regressor.hybridize()
  
      # Create random input and output data
      x = np.random.uniform(
          size=(64, 1000)
      )  # x is of type mxnet.numpy.ndarray
      regressor(x)
      y = np.random.uniform(
          size=(64, 10)
      )  # y is of type mxnet.numpy.ndarray
  
      total_loss = TotalLoss()
      total_loss.hybridize()
  
      trainer = gluon.Trainer(
          regressor.collect_params(),
          "sgd",
          {"learning_rate": 1e-3, "momentum": 0.9},
      )
  
      for _ in range(2):
          with autograd.record():
              output = regressor(
                  x
              )  # output is a type of np.ndarray because np.dot is the last op in the network
              loss = total_loss(
                  output, y
              )  # loss is a scalar np.ndarray
          loss.backward()
          trainer.step(1)
  
imports: from __future__ import absolute_import
  from __future__ import division
  import os
  from uuid import uuid4
  import numpy
  import mxnet
  from mxnet import gluon, autograd, np, npx
  from mxnet.test_utils import use_np, assert_almost_equal, check_gluon_hybridize_consistency, assert_allclose
  from mxnet.gluon import nn
  from mxnet.base import MXNetError
  import random
  import pytest
label_desc: Use image node_id 2 for calling a global function with example usage: test_optimizer_with_np_ndarrays() and returns: y_pred, unknown