code: def _validate_shape(shape):
      """Check that shape is a valid array shape."""
      if not isinstance(shape, abc.Iterable):
          raise TypeError(
              "shape must be a tuple or other iterable object, not %s"
              % type(shape).__name__
          )
  
      validated_shape = []
      for i, dim in enumerate(shape):
          if not dim or dim != int(dim) or int(dim) <= 0:
              raise ValueError(
                  "Dimension %d is invalid in %s, expected positive int"
                  % (i, shape)
              )
          validated_shape.append(int(dim))
  
      return tuple(validated_shape)
  
file_path: agents/tf_agents/utils/example_encoding.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from collections import abc
  import io
  import gin
  import numpy
  from PIL import Image
  import tensorflow
  from tf_agents.utils import nest_utils
label_desc: Use image node_id 4 for calling a global function with example usage: _validate_shape(shape) and returns: tuple