class_docstr: Interface between a TensorFlow model and a Thinc Model. This container is
  *not* a Thinc Model subclass itself.
  
  Reference for custom training:
  https://www.tensorflow.org/tutorials/customization/custom_training_walkthrough
class_docstr_tok: ["Interface","between","a","TensorFlow","model","and","a","Thinc","Model",".","This","container","is","*","not","*","a","Thinc","Model","subclass","itself",".","Reference","for","custom","training",":","https",":","\/\/www.tensorflow.org\/tutorials\/customization\/custom_training_walkthrough"]
code: def finish_update(self, optimizer: Optimizer):
      if self.gradients is None:
          raise ValueError(
              "There are no gradients for optimization. Be sure to call begin_update"
              " before calling finish_update."
          )
      assert len(self.gradients) == len(self._model.trainable_variables)
      grad: tf.Tensor
      variable: tf.Variable
      params = []
      grads = []
      shapes = []
  
      for grad, variable in zip(
          self.gradients, self._model.trainable_variables
      ):
          param = variable.numpy()
          grad = grad.numpy()
          shapes.append((param.size, param.shape))
          params.append(param.ravel())
          grads.append(grad.ravel())
      xp = get_array_module(params[0])
      flat_params, flat_grads = optimizer(
          (self.id, "tensorflow-shim"),
          xp.concatenate(params),
          xp.concatenate(grads),
      )
      start = 0
      for grad, variable in zip(
          self.gradients, self._model.trainable_variables
      ):
          size, shape = shapes.pop(0)
          param = flat_params[start : start + size].reshape(shape)
          variable.assign(param)
          start += size
      self.gradients = None
  
imports: import contextlib
  import copy
  from io import BytesIO
  from typing import Any, Dict, List, Optional
  import catalogue
  import numpy
  from ..backends import Ops, get_current_ops
  from ..compat import cupy, h5py
  from ..compat import tensorflow
  from ..optimizers import Optimizer
  from ..types import ArgsKwargs, ArrayXd
  from ..util import get_array_module
  from .shim import Shim
label_desc: Use image node_id 6 for calling the TensorFlowShim obj's underlying member method code with example usage: obj.finish_update(optimizer) without return types