class_docstr: Interface between a MXNet model and a Thinc Model. This container is
  *not* a Thinc Model subclass itself.
class_docstr_tok: ["Interface","between","a","MXNet","model","and","a","Thinc","Model",".","This","container","is","*","not","*","a","Thinc","Model","subclass","itself","."]
code: def finish_update(self, optimizer: Optimizer):
      params = []
      grads = []
      shapes = []
      ctx = mx.current_context()
      for key, value in self._model.collect_params().items():
          grad = cast(FloatsXd, mxnet2xp(value.grad(ctx)))
          param = cast(FloatsXd, mxnet2xp(value.data(ctx)))
          params.append(param.ravel())
          grads.append(grad.ravel())
          shapes.append((param.size, param.shape))
      if not params:
          return
      xp = get_array_module(params[0])
      flat_params, flat_grads = optimizer(
          (self.id, "mxnet-shim"),
          xp.concatenate(params),
          xp.concatenate(grads),
      )
      start = 0
      for key, value in self._model.collect_params().items():
          size, shape = shapes.pop(0)
          param = flat_params[start : start + size].reshape(shape)
          value.set_data(xp2mxnet(param))
          value.zero_grad()
          start += size
  
file_path: thinc/thinc/shims/mxnet.py
imports: import copy
  from typing import Any, cast
  import srsly
  from ..compat import mxnet
  from ..optimizers import Optimizer
  from ..types import ArgsKwargs, FloatsXd
  from ..util import convert_recursive, get_array_module, make_tempfile, mxnet2xp, xp2mxnet
  from .shim import Shim
label_desc: Use image node_id 4 for calling the MXNetShim obj's underlying member method code with example usage: obj.finish_update(optimizer) without return types