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 from_bytes(self, data):
      ops: Ops = get_current_ops()
      if ops.device_type == "cpu":
          device = "CPU"
      else:  # pragma: no cover
          device = tf.test.gpu_device_name()
  
      # Plain bytes
      if isinstance(data, (str, bytes)):
          tf.keras.backend.clear_session()
          filelike = BytesIO(data)
          filelike.seek(0)
          with h5py.File(filelike, "r") as f:
              with tf.device(device):
                  self._model = tf.keras.models.load_model(f)
              return
      # We only have to create the model if it doesn't already exist.
      catalogue_name, model_weights = data
      if self._model is None:
          model_fn = keras_model_fns.get(catalogue_name)
          tf.keras.backend.clear_session()
          with tf.device(device):
              if hasattr(self._model, "eg_args"):
                  ak: ArgsKwargs = self._model.eg_args
                  new_model = model_fn(*ak.args, **ak.kwargs)
              else:
                  new_model = model_fn()
          self._model_initialized = maybe_handshake_model(new_model)
      self._model.set_weights(model_weights)
  
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 14 for calling the TensorFlowShim obj's underlying member method code with example usage: obj.from_bytes(data) without return types