parameters: (var)
docstring: Returns variable(length) from shape ops based on var.type
  
      Note: In addition to some ast transformations, some block-related
            operations are added in `len` transformation, such as appending
            `shape_op` in var.block.
docstring_summary: Returns variable(length) from shape ops based on var.type
docstring_tokens: Returns variable ( length ) from shape ops based on var . type
function: def convert_len(var):
      """
      Returns variable(length) from shape ops based on var.type
  
      Note: In addition to some ast transformations, some block-related
            operations are added in `len` transformation, such as appending
            `shape_op` in var.block.
      """
      if isinstance(var, Variable):
          if var.type in [
                  core.VarDesc.VarType.LOD_TENSOR,
                  core.VarDesc.VarType.SELECTED_ROWS
          ]:
              # Note: Length of var may be known ahead of time in dygraph,
              # but it probably represents batch size which can be variant.
              # so we return a variable dynamically inferred from var.shape.
              return nn.shape(var)[0]
          elif var.type == core.VarDesc.VarType.LOD_TENSOR_ARRAY:
              return control_flow.array_length(var)
          else:
              raise TypeError(
                  'len(var) only supports LoDTensor/LoDTensorArray/SelectedRows, but received %s.'
                  % type(var))
      else:
          return len(var)
function_tokens: def convert_len ( var ) : if isinstance ( var , Variable ) : if var . type in [ core . VarDesc . VarType . LOD_TENSOR , core . VarDesc . VarType . SELECTED_ROWS ] : # Note: Length of var may be known ahead of time in dygraph, # but it probably represents batch size which can be variant. # so we return a variable dynamically inferred from var.shape. return nn . shape ( var ) [ 0 ] elif var . type == core . VarDesc . VarType . LOD_TENSOR_ARRAY : return control_flow . array_length ( var ) else : raise TypeError ( 'len(var) only supports LoDTensor/LoDTensorArray/SelectedRows, but received %s.' % type ( var ) ) else : return len ( var )