docstr: Check is_image_ratio with a feature that has partially images.
docstr_tok: ["Check","is_image_ratio","with","a","feature","that","has","partially","images","."]
code: def test_image_stats_generator_check_is_image_ratio(self):
      """Check is_image_ratio with a feature that has partially images."""
      # The image ratio is: 0.83
      batches = [
          pa.array(
              [
                  [
                      FakeImageDecoder.encode_image_metadata(
                          "PNG", 2, 4
                      ),
                      FakeImageDecoder.encode_image_metadata(
                          "JPEG", 4, 2
                      ),
                  ],
                  [
                      FakeImageDecoder.encode_image_metadata(
                          "TIFF", 5, 1
                      ),
                      FakeImageDecoder.encode_image_metadata(
                          "", -1, -1
                      ),
                      FakeImageDecoder.encode_image_metadata(
                          "TIFF", 3, 7
                      ),
                  ],
              ]
          ),
          pa.array(
              [
                  [
                      FakeImageDecoder.encode_image_metadata(
                          "GIF", 2, 1
                      ),
                  ]
              ]
          ),
      ]
      # For image_ratio_threshold=0.85 we for not expect stats.
      expected_result = statistics_pb2.FeatureNameStatistics()
      image_decoder = FakeImageDecoder()
      generator = image_stats_generator.ImageStatsGenerator(
          image_decoder=image_decoder,
          is_image_ratio_threshold=0.85,
          values_threshold=1,
          enable_size_stats=True,
      )
      self.assertCombinerOutputEqual(
          batches, generator, expected_result
      )
  
      # For image_ratio_threshold=0.8 we expect stats.
      expected_result = text_format.Parse(
          """
              custom_stats {
                name: 'domain_info'
                str: 'image_domain {}'
              }
              custom_stats {
                name: 'image_format_histogram'
                rank_histogram {
                  buckets {
                    label: 'UNKNOWN'
                    sample_count: 1
                  }
                  buckets {
                    label: 'GIF'
                    sample_count: 1
                  }
                  buckets {
                    label: 'JPEG'
                    sample_count: 1
                  }
                  buckets {
                    label: 'PNG'
                    sample_count: 1
                  }
                  buckets {
                    label: 'TIFF'
                    sample_count: 2
                  }
                }
              }
              custom_stats {
                name: 'image_max_width'
                num: 7.0
              }
              custom_stats {
                name: 'image_max_height'
                num: 5.0
              }
              """,
          statistics_pb2.FeatureNameStatistics(),
      )
      generator = image_stats_generator.ImageStatsGenerator(
          image_decoder=image_decoder,
          is_image_ratio_threshold=0.8,
          values_threshold=1,
          enable_size_stats=True,
      )
      self.assertCombinerOutputEqual(
          batches, generator, expected_result
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import json
  import os
  import pickle
  from absl.testing import absltest
  from absl.testing import parameterized
  import numpy
  import pyarrow
  import tensorflow
  from tensorflow_data_validation.statistics.generators import image_stats_generator
  from tensorflow_data_validation.utils import test_util
  from google.protobuf import text_format
  from tensorflow_metadata.proto.v0 import statistics_pb2
label_desc: Use image node_id 4 for calling the ImageStatsGeneratorTest obj's underlying member method code with example usage: obj.test_image_stats_generator_check_is_image_ratio() without return types