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 to_bytes(self):
      filelike = BytesIO()
      try:
          with h5py.File(filelike, "w") as f:
              self._model.save(f, save_format="h5")
          return filelike.getvalue()
      except NotImplementedError:
          if not hasattr(self._model, "catalogue_name"):
              raise ValueError(
                  "Couldn't serialize to h5, and model has no factory "
                  "function for component serialization."
              )
      # Check the factory function and throw ValueError if it doesn't exist
      keras_model_fns.get(self._model.catalogue_name)
      return self._model.catalogue_name, self._model.get_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 13 for calling the TensorFlowShim obj's underlying member method code with example usage: obj.to_bytes() and returns: self,  self, filelike