class_docstr: Image preprocessing layer (specification key: `image`).
  
  Args:
      height (int): Height of resized image
          (<span style="color:#00C000"><b>default</b></span>: no resizing or relative to width).
      width (int): Width of resized image
          (<span style="color:#00C000"><b>default</b></span>: no resizing or relative to height).
      grayscale (bool | iter[float]): Turn into grayscale image, optionally using given weights
          (<span style="color:#00C000"><b>default</b></span>: false).
      name (string): Layer name
          (<span style="color:#00C000"><b>default</b></span>: internally chosen).
      input_spec (specification): <span style="color:#00C000"><b>internal use</b></span>.
class_docstr_tok: ["Image","preprocessing","layer","(","specification","key",":","`","image","`",")",".","Args",":","height","(","int",")",":","Height","of","resized","image","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","no","resizing","or","relative","to","width",")",".","width","(","int",")",":","Width","of","resized","image","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","no","resizing","or","relative","to","height",")",".","grayscale","(","bool","|","iter","[","float","]",")",":","Turn","into","grayscale","image",",","optionally","using","given","weights","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","false",")",".","name","(","string",")",":","Layer","name","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","internally","chosen",")",".","input_spec","(","specification",")",":","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","internal","use","<","\/b",">","<","\/span",">","."]
code: def apply(self, *, x):
      if self.height is not None:
          x = tf.image.resize(images=x, size=(self.height, self.width))
  
      if not isinstance(self.grayscale, bool):
          weights = tf_util.constant(
              value=self.grayscale,
              dtype="float",
              shape=(1, 1, 1, len(self.grayscale)),
          )
          x = tf.reduce_sum(
              input_tensor=(x * weights), axis=3, keepdims=True
          )
      elif self.grayscale:
          x = tf.image.rgb_to_grayscale(images=x)
  
      return x
  
imports: import tensorflow
  from tensorforce.core import parameter_modules, SignatureDict, TensorSpec, tf_function, tf_util
  from tensorforce.core.layers import Layer
label_desc: Use image node_id 4 for calling the Image obj's underlying member method code with example usage: obj.apply() and returns: x